android 线性布局LinearLayout的填充空白的技巧,你需要一个空白的控件来填充满其余的空白部分,
在一个线性布局中,确定有内容的控件后,你需要一个空白的控件来填充满其余的空白部分,
在已线性布局只有一个控件使用比重,这个控件会在其它控件长度确定后,自动填充满布局
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="8dp"
android:layout_weight="4"
android:gravity="center_vertical"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="13sp"
android:text="计划完成金额"
android:textColor="@color/word_black3"
/>
<TextView
android:id="@+id/PaymentPlan_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:textColor="@color/red_background"
android:textSize="14sp" />
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<TextView
android:id="@+id/PaymentPlan_number"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:text="次号:"
android:textColor="@color/word_grey7"
android:textSize="12sp" />
</LinearLayout>
以下就是这个控件自动填充满布局:
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
效果图: