我正在设计我的应用程序 UI。我需要这样的布局:
(< 和 > 是按钮)。问题是,我不知道如何确保 TextView 将填充剩余空间,两个按钮的大小是固定的。
如果我对 TextView 使用 fill_parent,则无法显示第二个按钮 (>)。
如何制作看起来像图像的布局?
最佳答案
woodshy 的回答对我有用,它比 Ungureanu Liviu 的回答简单,因为它不使用 RelativeLayout
。
为了清楚起见,我给出了我的布局:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<Button
android:layout_width = "80dp"
android:layout_weight = "0"
android:layout_height = "wrap_content"
android:text="<"/>
<TextView
android:layout_width = "fill_parent"
android:layout_height = "wrap_content"
android:layout_weight = "1"/>
<Button
android:layout_width = "80dp"
android:layout_weight = "0"
android:layout_height = "wrap_content"
android:text=">"/>
</LinearLayout>
关于android - 如何使用 View 使布局填充剩余空间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6316540/