您可以使用重量参数。
“权重”是一个术语,用于指定特定视图在绘制后是否还有空间时应占据屏幕的多少。
只需制作一个LinearLayout
并在其中放置两个TextViews
:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="small"
android:layout_weight="0.2"
android:background="#123" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.8"
android:text="huge"
android:background="#456"
/>
</LinearLayout>
您会注意到视图如何相应地占用空间。您可以为较小的屏幕创建任何您想要的布局并指定权重属性,并且每件事都会得到精美的调整