gpt4 book ai didi

android - 如何构建 "right to left"线性布局?

转载 作者:行者123 更新时间:2023-11-30 02:10:40 25 4
gpt4 key购买 nike

我想制作一个聊天室气泡 ListView ,但遇到了一个问题;右侧气泡布局xml如下

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="end"
android:orientation="horizontal" >

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

<ImageView
android:id="@+id/portrait"
android:layout_width="40dip"
android:layout_height="40dip" />

</LinearLayout>

结果和图片一样,为什么会超出左边框

enter image description here

最佳答案

试试这个:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
>

<TextView
android:id="@+id/textMsg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/portrait"
/>

<ImageView
android:id="@+id/portrait"
android:layout_width="40dip"
android:layout_height="40dip"
android:layout_alignParentRight="true"
/>

</RelativeLayout>

关于android - 如何构建 "right to left"线性布局?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30148698/

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