我有三个片段,前两个填充80%的屏幕,最后一个填充其余的片段(这个片段永远不会改变大小).我希望,在用户(焦点)输入片段后,调整片段的大小,使其填满屏幕的70%(将10%留给另一个).像这样:
可以通过动态改变碎片的重量吗?
或者有更好的方法来实现这一目标?
这是我现在在XML中的代码:
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1.0">
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".8">
android:id="@+id/MainLinear"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="1.0">
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight=".5"/>
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight=".5"/>
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight=".2"/>