如何在相对布局中水平设置两个文本视图相等的大小

马纳兹赛义德 |
  <RelativeLayout
            android:id="@+id/footer"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_gravity="center"
            android:background="#b4d3d3">

            <TextView
                android:id="@+id/hello"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:background="#5d737e"
                android:padding="20dp"
                android:text="First" />

            <TextView
                android:id="@+id/world"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_alignTop="@+id/hello"
                android:padding="20dp"
                android:text="Second" />

        </RelativeLayout>

这是我的 xml 我想在相对布局中设置两个 textview 相等的部分horzontally 但是使用这个 xml 左侧的 textview 只出现了很少的部分而右侧的一个占用了很多空间请告诉我我做错了什么。

明努卡亚埃
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    android:id="@+id/footer"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_gravity="center"
    android:background="#b4d3d3">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">

<TextView
    android:id="@+id/hello"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:background="#5d737e"
    android:padding="20dp"
    android:layout_weight="1"
    android:text="First" />

<TextView
    android:id="@+id/world"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_alignTop="@+id/hello"
    android:padding="20dp"
    android:layout_weight="1"
    android:text="Second" />
</LinearLayout>

</RelativeLayout>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何在android中的相对布局内设置与父文本视图对齐的文本视图?

如何在恒定间距的约束布局中居中放置两个文本视图?

如何在水平滚动视图中在两个对象周围有相等的边距?

如何在相对布局中水平放置视图等距?

如何在图像视图和相对布局中设置Alpha

如何使2个水平按钮相等地填充相对布局?

在两个视图上设置左右属性时,相对布局会消失两个视图

如何在LinearLayout的相对侧放置两个视图

如何在 Android Studio 的圆形布局内居中两个文本视图?

主要相对布局中两个相对布局的对齐

在列表项中水平对齐两个文本视图

如何在一个按钮中设置两个不同大小的文本,Android API> 24

如何在R中合并两个不相等大小的数据帧

如何显示两个水平的文本视图,其中一个根据内容调整大小?

如何在约束布局中水平匹配两个元素?

如何在WPF中为两个文本框网格动态设置字体大小

如何在一个ListView中设置两个布局

如何在RelativeLayout中的两个视图之间填充布局?

如何在Android布局的片段中添加两个列表视图?

如何使用大小类和自动布局将两个UI按钮在Xib中水平对齐

如何在xml布局中添加两个Scroll视图,以使每个scrollview占据布局高度的一半?

如何在一个JFrame中设置两个JPanel的大小?

如何在Android中将活动的背景图像设置为水平和垂直两个不同大小

如何在一个屏幕上使用两个相对布局?

如何在相对布局或任何布局中动态添加视图

如何在Zend框架的控制器中设置两个视图

如何在TensorFlow中水平连接两个张量?

如何在html中水平对齐两个按钮

如何在相对布局中连续定位中心水平 2 个元素