问题是这样的,我做一个能收起来的webview效果,代码逻辑很简单,修改linearlayout高度来实现收起效果。 但是发现一个非常奇怪的问题,在android4.1(API16)上这这个简单操作的时候总是闪退,而且没有任何奔溃日志,我就纳闷了,找了两天后来发现掉进了大坑。 把布局文件中的最外层RelativeLayout改成Linearlatout就不会闪退了。虽然解决了,但是真的这是为什么!?求大神指导 当然,毕竟android出点意料之外的事才是正常的。 布局文件: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <Button android:id="@+id/test_bt" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="改变"/> <LinearLayout android:id="@+id/test_ll" android:layout_width="match_parent" android:layout_height="100dp" android:layout_below="@+id/test_bt"> <WebView android:id="@+id/test_wv" android:layout_width="match_parent" android:layout_height="wrap_content"></WebView> </LinearLayout> </RelativeLayout> activity中修改linearlayout高度的代码LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) linearLayout.getLayoutParams(); lp.height = UIUtils.px2dip(200); linearLayout.setLayoutParams(lp);
android开发android4.1(API16)修改linearlayout高度闪退
最新推荐文章于 2021-08-23 10:08:13 发布