出现问题;
Exception raised during rendering: ScrollView can host only one direct child
翻译;渲染期间抛出异常:ScrollView只能托管一个直接子代
解决方案:
多个布局放在一个layout里面 然后外层放ScrollView
更改前代码:
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.yoolink.ui.fragment.trade.wechatpay.Trade2Fragment"> <LinearLayout style="@style/bmItem_lin_all"> <LinearLayout android:id="@+id/bm_1" style="@style/bmItem_lin"> <TextView style="@style/bmItem_text" android:text="生 活 缴 费" /> <ImageView style="@style/bmItem_img" android:src="@drawable/bm_jiaofei" /> </LinearLayout> <LinearLayout android:id="@+id/bm_2" style="@style/bmItem_lin"> <TextView style="@style/bmItem_text" android:text="微 信 支 付" /> <ImageView style="@style/bmItem_img" android:src="@drawable/bm_wechat" /> </LinearLayout> </LinearLayout> <LinearLayout style="@style/bmItem_lin_all"> <LinearLayout android:id="@+id/bm_3" style="@style/bmItem_lin"> <TextView style="@style/bmItem_text" android:text="火车票订购" /> <ImageView style="@style/bmItem_img" android:src="@drawable/bm_hcp" /> </LinearLayout> <LinearLayout android:id="@+id/bm_4" style="@style/bmItem_lin"> <TextView style="@style/bmItem_text" android:text="支付宝支付" /> <ImageView style="@style/bmItem_img" android:src="@drawable/bm_zfb" /> </LinearLayout> </LinearLayout> <LinearLayout style="@style/bmItem_lin_all"> <LinearLayout android:id="@+id/bm_5" style="@style/bmItem_lin"> <TextView style="@style/bmItem_text" android:text="飞机票订购" /> <ImageView style="@style/bmItem_img" android:src="@drawable/bm_fjp" /> </LinearLayout> <LinearLayout android:id="@+id/bm_6" style="@style/bmItem_lin"> <TextView style="@style/bmItem_text" android:text="信用卡还款" /> <ImageView style="@style/bmItem_img" android:src="@drawable/bm_xyk" /> </LinearLayout> </LinearLayout> <LinearLayout style="@style/bmItem_lin_all"> <LinearLayout android:id="@+id/bm_7" style="@style/bmItem_lin"> <TextView style="@style/bmItem_text" android:text="电 影 购 票" /> <ImageView style="@style/bmItem_img" android:src="@drawable/bm_dy" /> </LinearLayout> <LinearLayout android:id="@+id/bm_8" style="@style/bmItem_lin"> <TextView style="@style/bmItem_text" android:text="游 戏 充 值" /> <ImageView style="@style/bmItem_img" android:src="@drawable/bm_yxcz" /> </LinearLayout> </LinearLayout> <LinearLayout style="@style/bmItem_lin_all"> <LinearLayout android:id="@+id/bm_9" style="@style/bmItem_lin"> <TextView style="@style/bmItem_text" android:text="手 机 充 值" /> <ImageView style="@style/bmItem_img" android:src="@drawable/bm_sjcz" /> </LinearLayout> <LinearLayout android:id="@+id/bm_10" style="@style/bmItem_lin"> <TextView style="@style/bmItem_text" android:text="彩 票 购 买" /> <ImageView style="@style/bmItem_img" android:src="@drawable/bm_cpgm" /> </LinearLayout> </LinearLayout> <LinearLayout style="@style/bmItem_lin_all"> <LinearLayout android:id="@+id/bm_11" style="@style/bmItem_lin"> <TextView style="@style/bmItem_text" android:text="酒 店 预 订" /> <ImageView style="@style/bmItem_img" android:src="@drawable/bm_jdyd" /> </LinearLayout> <LinearLayout android:id="@+id/bm_12" style="@style/bmItem_lin"> <TextView style="@style/bmItem_text" android:text="交 通 违 章" /> <ImageView style="@style/bmItem_img" android:src="@drawable/bm_jtwz" /> </LinearLayout> </LinearLayout> <LinearLayout style="@style/bmItem_lin_all"> <LinearLayout android:id="@+id/bm_13" style="@style/bmItem_lin"> <TextView style="@style/bmItem_text" android:text="保 险 理 财" /> <ImageView style="@style/bmItem_img" android:src="@drawable/bm_bxlc" /> </LinearLayout> </LinearLayout></LinearLayout>修改后:<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.yoolink.ui.fragment.trade.wechatpay.Trade2Fragment"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/movie_background" android:orientation="vertical"> <LinearLayout style="@style/bmItem_lin_all"> <LinearLayout android:id="@+id/bm_1" style="@style/bmItem_lin"> <TextView style="@style/bmItem_text" android:text="生 活 缴 费" /> <ImageView style="@style/bmItem_img" android:src="@drawable/bm_jiaofei" /> </LinearLayout> <LinearLayout android:id="@+id/bm_2" style="@style/bmItem_lin"> <TextView style="@style/bmItem_text" android:text="微 信 支 付" /> <ImageView style="@style/bmItem_img" android:src="@drawable/bm_wechat" /> </LinearLayout> </LinearLayout> <LinearLayout style="@style/bmItem_lin_all"> <LinearLayout android:id="@+id/bm_3" style="@style/bmItem_lin"> <TextView style="@style/bmItem_text" android:text="火车票订购" /> <ImageView style="@style/bmItem_img" android:src="@drawable/bm_hcp" /> </LinearLayout> <LinearLayout android:id="@+id/bm_4" style="@style/bmItem_lin"> <TextView style="@style/bmItem_text" android:text="支付宝支付" /> <ImageView style="@style/bmItem_img" android:src="@drawable/bm_zfb" /> </LinearLayout> </LinearLayout> <LinearLayout style="@style/bmItem_lin_all"> <LinearLayout android:id="@+id/bm_5" style="@style/bmItem_lin"> <TextView style="@style/bmItem_text" android:text="飞机票订购" /> <ImageView style="@style/bmItem_img" android:src="@drawable/bm_fjp" /> </LinearLayout> <LinearLayout android:id="@+id/bm_6" style="@style/bmItem_lin"> <TextView style="@style/bmItem_text" android:text="信用卡还款" /> <ImageView style="@style/bmItem_img" android:src="@drawable/bm_xyk" /> </LinearLayout> </LinearLayout> <LinearLayout style="@style/bmItem_lin_all"> <LinearLayout android:id="@+id/bm_7" style="@style/bmItem_lin"> <TextView style="@style/bmItem_text" android:text="电 影 购 票" /> <ImageView style="@style/bmItem_img" android:src="@drawable/bm_dy" /> </LinearLayout> <LinearLayout android:id="@+id/bm_8" style="@style/bmItem_lin"> <TextView style="@style/bmItem_text" android:text="游 戏 充 值" /> <ImageView style="@style/bmItem_img" android:src="@drawable/bm_yxcz" /> </LinearLayout> </LinearLayout> <LinearLayout style="@style/bmItem_lin_all"> <LinearLayout android:id="@+id/bm_9" style="@style/bmItem_lin"> <TextView style="@style/bmItem_text" android:text="手 机 充 值" /> <ImageView style="@style/bmItem_img" android:src="@drawable/bm_sjcz" /> </LinearLayout> <LinearLayout android:id="@+id/bm_10" style="@style/bmItem_lin"> <TextView style="@style/bmItem_text" android:text="彩 票 购 买" /> <ImageView style="@style/bmItem_img" android:src="@drawable/bm_cpgm" /> </LinearLayout> </LinearLayout> <LinearLayout style="@style/bmItem_lin_all"> <LinearLayout android:id="@+id/bm_11" style="@style/bmItem_lin"> <TextView style="@style/bmItem_text" android:text="酒 店 预 订" /> <ImageView style="@style/bmItem_img" android:src="@drawable/bm_jdyd" /> </LinearLayout> <LinearLayout android:id="@+id/bm_12" style="@style/bmItem_lin"> <TextView style="@style/bmItem_text" android:text="交 通 违 章" /> <ImageView style="@style/bmItem_img" android:src="@drawable/bm_jtwz" /> </LinearLayout> </LinearLayout> <LinearLayout style="@style/bmItem_lin_all"> <LinearLayout android:id="@+id/bm_13" style="@style/bmItem_lin"> <TextView style="@style/bmItem_text" android:text="保 险 理 财" /> <ImageView style="@style/bmItem_img" android:src="@drawable/bm_bxlc" /> </LinearLayout> <LinearLayout android:id="@+id/bm_14" style="@style/bmItem_lin"> <TextView style="@style/bmItem_text" android:text="医 护 救 援" /> <ImageView style="@style/bmItem_img" android:src="@drawable/bm_yhjy" /> </LinearLayout> </LinearLayout> <LinearLayout style="@style/bmItem_lin_all"> <LinearLayout android:id="@+id/bm_15" style="@style/bmItem_lin"> <TextView style="@style/bmItem_text" android:text="家 政 搬 家" /> <ImageView style="@style/bmItem_img" android:src="@drawable/bm_jzbj" /> </LinearLayout> <LinearLayout android:id="@+id/bm_16" style="@style/bmItem_lin"> <TextView style="@style/bmItem_text" android:text="家 电 维 修" /> <ImageView style="@style/bmItem_img" android:src="@drawable/bm_jdwx" /> </LinearLayout> </LinearLayout> <LinearLayout style="@style/bmItem_lin_all"> <LinearLayout android:id="@+id/bm_17" style="@style/bmItem_lin"> <TextView style="@style/bmItem_text" android:text="房 屋 租 赁" /> <ImageView style="@style/bmItem_img" android:src="@drawable/bm_fwzl" /> </LinearLayout> <LinearLayout android:id="@+id/bm_18" style="@style/bmItem_lin"> <TextView style="@style/bmItem_text" android:text="修 车 保 养" /> <ImageView style="@style/bmItem_img" android:src="@drawable/bm_xcby" /> </LinearLayout> </LinearLayout> <LinearLayout style="@style/bmItem_lin_all"> <LinearLayout android:id="@+id/bm_19" style="@style/bmItem_lin"> <TextView style="@style/bmItem_text" android:text="快 递 服 务" /> <ImageView style="@style/bmItem_img" android:src="@drawable/bm_kdfw" /> </LinearLayout> <LinearLayout android:id="@+id/bm_20" style="@style/bmItem_lin"> <TextView style="@style/bmItem_text" android:text="商 品 溯 源" /> <ImageView style="@style/bmItem_img" android:src="@drawable/bm_spsy" /> </LinearLayout> </LinearLayout> </LinearLayout></ScrollView>
新闻热点
疑难解答