gpt4 book ai didi

android - 布局文件 - 将项目定位到另一个项目的右侧 (Android)

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

我试图将 RelativeLayout 中的一项定位到另一项的右侧。在下面的示例中,我希望将“,”放置在描述字段的右侧。但是问题是它将逗号放在名称字段旁边的第一行。谁能帮忙?

<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:padding="10sp">
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/name" />
<TextView
android:id="@+id/descriptioncomma"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=", "
android:layout_toRightOf="@id/description" />

最佳答案

试试这段代码,它应该可以工作:按钮使用带有 Textview 小部件 ID 的 layout_toRightOf 属性。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:padding="10sp">
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/name" />
<TextView
android:id="@+id/descriptioncomma"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=","
android:layout_below="@id/name"
android:layout_toRightOf="@id/description" />
</RelativeLayout>

在两个 TextView 中,您都可以添加文本并检查它。

好的

关于android - 布局文件 - 将项目定位到另一个项目的右侧 (Android),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7305789/

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