如何使布局与视图填充剩余空间? [英] How to make layout with View fill the remaining space?

查看:33
本文介绍了如何使布局与视图填充剩余空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设计我的应用程序 UI.我需要一个看起来像这样的布局:

I'm designing my application UI. I need a layout looks like this:

(<和 > 是按钮).问题是,我不知道如何确保 TextView 将填充剩余空间,两个按钮的大小是固定的.

(< and > are Buttons). The problem is, I don't know how to make sure the TextView will fill the remaining space, with two buttons have fixed size.

如果我对文本视图使用 fill_parent,则无法显示第二个按钮 (>).

If I use fill_parent for Text View, the second button (>) can't be shown.

如何制作与图像相似的布局?

How can I craft a layout that looks like the image?

推荐答案

woodshy 的回答对我有用,它比 Ungureanu Liviu 的回答简单,因为它不使用 RelativeLayout.为了清楚起见,我给出了我的布局:

Answer from woodshy worked for me, and it is simpler than the answer by Ungureanu Liviu since it does not use RelativeLayout. I am giving my layout for clarity:

<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>

这篇关于如何使布局与视图填充剩余空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆