gpt4 book ai didi

android - 一个简单的相对布局,与父级右对齐不起作用

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:00:01 25 4
gpt4 key购买 nike

我做了一个简单的相对布局,里面只有3个TextView,代码如下:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>

<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>

<!--Why this "age" TextView is not align to parent right?-->
<TextView
android:id="@+id/age"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/name"
android:layout_alignParentRight="true"/>

<TextView
android:id="@+id/gender"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/name"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"/>

</RelativeLayout>

我希望第二个 TextView(id="age") 位于右侧,所以我使用 layout_alignParentRight="true",但是,它始终显示在第一个 TextView(id="name") 之后,为什么?为什么它不转到父级右边(最右边)?

最佳答案

删除这个:

android:layout_toRightOf="@id/name"

从TextView时代开始

关于android - 一个简单的相对布局,与父级右对齐不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10945205/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com