gpt4 book ai didi

android相对布局设计

转载 作者:行者123 更新时间:2023-11-29 21:04:55 24 4
gpt4 key购买 nike

enter image description here

我想在android中设计这个布局,我试过的是这个。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:textColor="#0196d5"
android:text="Recent"
/>

<TextView
android:id="@+id/txtLikeCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#0196d5"
android:layout_alignParentRight="true"
android:text="10"
/>

<TextView
android:id="@+id/txtCommentCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#0196d5"
android:layout_alignRight="@id/txtLikeCount"
android:text="20"
/>



</RelativeLayout>
<TextView
android:id="@+id/txtStatus"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="Some text to show."
android:background="#0196d5"
android:textColor="#fff"
/>




</LinearLayout>

但这是显示文本 10 和 20 相互重叠的 TextView 。而且我也没有添加拇指和气球弹出的图像。但我会添加它,只要告诉我我做错了什么。

其次,我在顶行使用相对布局,我可以使用线性布局吗?

最佳答案

这是 android:layout_alignRight 的预期行为。文档说

Makes the right edge of this view match the right edge of the given anchor view ID.

您应该根据需要使用 android:layout_toRightOfandroid:layout_toLeftOf

关于android相对布局设计,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24860695/

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