如何使用View填充剩余空间来创建布局?

220
我正在设计我的应用程序UI。我需要一个布局看起来像这样: (<和>是按钮)。问题是,我不知道如何确保TextView填充剩余的空间,同时两个按钮具有固定大小。
如果我为Text View使用fill_parent,则第二个按钮(>)无法显示。
如何创建一个类似于图片的布局?

你使用什么作为根布局? - woodshy
1
@woodshy 任何布局都可以,无所谓。 - Luke Vo
12个回答

0

我找到了

 <TextView
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_marginEnd="10dp"
        android:fontFamily="casual"
        android:text="(By Zeus B0t)"
     ``   android:textSize="10sp"
        android:gravity="bottom"
        android:textStyle="italic" />

0
使用RelativeLayout来包装LinearLayout。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:round="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical">
    <Button
        android:layout_width = "wrap_content"
        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 = "wrap_content"
        android:layout_height = "wrap_content"
        android:text="&gt;"/>

</LinearLayout>

</RelativeLayout>`

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接