android - 如何使用 View 使布局填充剩余空间?

标签 android layout android-layout

我正在设计我的应用程序 UI。我需要这样的布局:

Example of desired layout

(< 和 > 是按钮)。问题是,我不知道如何确保 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="&lt;"/>
     <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="&gt;"/>   
 </LinearLayout>

关于android - 如何使用 View 使布局填充剩余空间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6316540/

相关文章:

c# - 未设置 Xamarin Forms 文件提供程序

android - 是否可以在不在 android 的 firestore 中创建文档的情况下将子集合添加到集合中?

android - 有没有办法在 Android 上的 Flutter 应用程序中拦截 'Back' keydown?

android - Android 中的样式继承

android - 单击按钮时如何提供 SlideUp 效果

android - 如何在安卓应用中提及用户

java - Swing MigLayout - 当空间不足时缩小标签

android - 关于这个 UI 实现的建议?

android - 使用 3d 翻转动画开始 Activity

android - 在 Android 的 LinearLayout 中居中对齐 TextView