【发布时间】:2017-08-11 11:05:59
【问题描述】:
我正面临安卓设计问题,我不明白为什么会发生它很奇怪。
我的布局代码:
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp">
<RelativeLayout
android:id="@+id/outgoing_layout_bubble"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="60dp"
android:layout_marginRight="8dp"
android:background="@drawable/chatrectbg"
android:padding="10dp"
android:visibility="visible">
<TextView
android:id="@+id/message"
style="@style/chat_text_message_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toStartOf="@+id/time"
android:autoLink="web"
android:paddingRight="10dp"
android:text="@{chat.messageText}"
android:textColor="@android:color/white"
android:textStyle="bold" />
<TextView
android:id="@id/time"
style="@style/chat_timings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginRight="4dp"
android:padding="5dp"
android:paddingRight="10dp"
android:text="@{chat.messageTime}"
android:textColor="@android:color/white"
android:textStyle="bold" />
</RelativeLayout>
</RelativeLayout>
我想要改变背景颜色环绕文本,但它没有。 我不明白我做错了什么?
【问题讨论】:
-
删除 *android:layout_alignParentBottom="true",你给了父底部,所以你的时间文本在视图的底部。
-
thanx 兄弟,你解决了我的一个问题,其他剩余的相对宽度没有被文本包裹
-
去掉relativeLAyout作为主布局,取线性垂直
-
@MuthukrishnanRajendran 你给出了正确的建议兄弟,只需删除 android:layout_alignParentBottom="true" 这将是完美的。
-
我在下面添加了我的答案,看看,您可以将 RelativeLayout 添加为 root,如果您将 RelativLayout 提供给 root 视图,请提供 android:layout_alignParentRight="true " 到内部线性,这样它就会向右走
标签: android android-layout android-relativelayout android-xml