我想改变 ScrollView 的权重,但我找不到方法。
这是我的 XML:
<ScrollView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:id="@+id/firstScrollView">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
...
</LinearLayout>
**other layout..
</ScrollView>
从代码中我只能设置scrollView的高度或宽度,我应该为权重写什么?
ViewGroup.LayoutParams scrollParams = new ViewGroup.LayoutParams(width,height);
scrollView.setLayoutParams(scrollParams);
最佳答案
LinearLayout.LayoutParams scrollParams = new LinearLayout.LayoutParams(width,height,2.0f);
scrollView.setLayoutParams(scrollParams);
构造函数中的最后一个选项是权重
关于android - 以编程方式更改 ScrollView 权重,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28481618/