开发遇到的奇葩问题
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <!--商品质检--> <LinearLayout android:id="@+id/commodity_quality_testing2_lv" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="@dimen/margin9" android:background="@color/white" android:gravity="center" android:orientation="vertical" android:paddingLeft="@dimen/margin10" android:paddingRight="@dimen/margin10"> <RelativeLayout android:layout_width="match_parent" android:layout_height="@dimen/userlineheight" android:background="@color/white" > <ImageView android:id="@+id/commodity_quality_testing2_img" android:layout_width="@dimen/commodity_quality_testing_img_width" android:layout_height="@dimen/commodity_quality_testing_img_width" android:layout_centerVertical="true" android:layout_marginRight="@dimen/margin5" android:background="@drawable/commodity_quality_testing_img" /> <TextView style="@style/user_txt_style" android:layout_centerVertical="true" android:layout_toRightOf="@id/commodity_quality_testing2_img" android:text="@string/commodity_quality_testing" android:textColor="@color/green" android:textSize="@dimen/txt_twosize" /> <ImageView style="@style/right_arrow_style" /> </RelativeLayout> <View style="@style/line_style" /> <LinearLayout android:layout_width="fill_parent" android:layout_height="@dimen/commodity_quality_testing_lv_height" android:visibility="gone" android:gravity="center" android:orientation="horizontal"> <LinearLayout android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:gravity="center" android:orientation="vertical"> <ImageView android:id="@+id/commodity_quality_testing2_one_img" android:layout_width="@dimen/commodity_quality_testing_img2_width" android:layout_height="@dimen/commodity_quality_testing_img2_width" android:layout_gravity="center" android:layout_marginBottom="@dimen/margin5" android:background="@drawable/jiancex" /> <TextView android:id="@+id/commodity_quality_testing2_one_tv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="中国" android:textColor="@color/gray_five" android:textSize="@dimen/txt_sevensize" /> </LinearLayout> <View style="@style/h_line_style" android:layout_height="@dimen/commodity_state_line_height" android:layout_gravity="center" android:background="@color/gray_fourteen" /> <LinearLayout android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:gravity="center" android:orientation="vertical"> <ImageView android:id="@+id/commodity_quality_testing2_two_img" android:layout_width="@dimen/commodity_quality_testing_img2_width" android:layout_height="@dimen/commodity_quality_testing_img2_width" android:layout_gravity="center" android:layout_marginBottom="@dimen/margin5" android:background="@drawable/jiancece2" /> <TextView android:id="@+id/commodity_quality_testing2_two_tv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="450/罐" android:textColor="@color/gray_five" android:textSize="@dimen/txt_sevensize" /> </LinearLayout> <View style="@style/h_line_style" android:layout_height="@dimen/commodity_state_line_height" android:layout_gravity="center" android:background="@color/gray_fourteen" /> <LinearLayout android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:gravity="center" android:orientation="vertical"> <ImageView android:id="@+id/commodity_quality_testing2_three_img" android:layout_width="@dimen/commodity_quality_testing_img2_width" android:layout_height="@dimen/commodity_quality_testing_img2_width" android:layout_gravity="center" android:layout_marginBottom="@dimen/margin5" android:background="@drawable/jiancex" /> <TextView android:id="@+id/commodity_quality_testing2_three_tv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="预售品" android:textColor="@color/gray_five" android:textSize="@dimen/txt_sevensize" /> </LinearLayout> <View style="@style/h_line_style" android:layout_height="@dimen/commodity_state_line_height" android:layout_gravity="center" android:background="@color/gray_fourteen" /> <LinearLayout android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:gravity="center" android:orientation="vertical"> <ImageView android:id="@+id/commodity_quality_testing2_four_img" android:layout_width="@dimen/commodity_quality_testing_img2_width" android:layout_height="@dimen/commodity_quality_testing_img2_width" android:layout_gravity="center" android:layout_marginBottom="@dimen/margin5" android:background="@drawable/jiancece2" /> <TextView android:id="@+id/commodity_quality_testing2_four_tv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="预售品" android:textColor="@color/gray_five" android:textSize="@dimen/txt_sevensize" /> </LinearLayout> </LinearLayout> </LinearLayout> <LinearLayout android:id="@+id/product_specification_lv" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="@dimen/margin9" android:background="@color/white" android:gravity="center" android:orientation="vertical" android:paddingLeft="@dimen/margin10" android:paddingRight="@dimen/margin10"> <android.support.v7.widget.RecyclerView android:id="@+id/rv_commodity_specification" android:layout_width="match_parent" android:layout_height="fill_parent" android:overScrollMode="never" android:scrollbars="none"/> <!-- <TextView android:id="@+id/product_specification_tv" android:layout_width="fill_parent" android:layout_height="@dimen/commodity_quality_testing_lv_height" android:gravity="center_vertical" android:textColor="@color/gray_four" android:textSize="@dimen/txt_foursize" /> <View style="@style/line_style" /> <TextView android:id="@+id/quality_guarantee_period_tv" android:layout_width="fill_parent" android:layout_height="@dimen/commodity_quality_testing_lv_height" android:gravity="center_vertical" android:textColor="@color/gray_four" android:textSize="@dimen/txt_foursize" /> <View style="@style/line_style" />--> </LinearLayout> <WebView android:id="@+id/webview" android:visibility="visible" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="@dimen/margin9"> </WebView> </LinearLayout> </LinearLayout>
布局上面这样,然后在代码中如果没有执行下面这句话,就会无缘无故崩溃,而且没有崩溃日志,一点排查才发现是这个问题
webview.loadData("", "text/html; charset=UTF-8", null); // 加载定义的代码,并设定编码格式和字符集
作者: 一点点征服
出处:http://www.cnblogs.com/ldq2016/
本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接,否则保留追究法律责任的权利