繁体   English   中英

在Android中将RelativeLayout对齐到底部

[英]Align a RelativeLayout to bottom in android

我使用以下代码创建聊天元素,但ImageView显示了未对齐的设计。 布局显示像这样当我运行该程序,¿我如何阿玲名为“阿凡达”到RelativeLayout的底部的视图?

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="@dimen/stixchat_margin_8"
android:layout_marginRight="@dimen/margin_item_chat_right"
android:layout_marginTop="@dimen/stixchat_margin_8"
>

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/content_avatar"
    android:orientation="vertical"
    >


    <com.trongphuc.emoappchat.FriendProfileImageViewLast
        android:id="@+id/avatar"
        android:layout_width="62dp"
        android:layout_height="62dp"
        android:layout_marginLeft="10dp"

        />
</LinearLayout>



<RelativeLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/bubble_test"
    android:id="@+id/content_content"
    >

    <TextView
        android:id="@+id/content"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="4dp"
        android:text="New Text"
        android:lineSpacingMultiplier="@dimen/chat_text_spacing"
        android:textAppearance="@style/StixChatText.Primary.Light"
        android:textColor="@android:color/white" />

</RelativeLayout>



<ImageView
    android:id="@+id/check"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerVertical="true"
    android:layout_alignParentLeft="true"
    android:src="@drawable/box_checkk"
    android:padding="@dimen/stixchat_margin_16"/>

<RelativeLayout
    android:id="@+id/item_chat_status_root"
    android:layout_below="@+id/content_content"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toRightOf="@+id/content_avatar"
    android:layout_marginLeft="@dimen/stixchat_margin_8"
    android:visibility="gone">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:textSize="10dp"
        android:text="24/03/2016 at 20:20"
        android:id="@+id/item_chat_status_tv" />
</RelativeLayout>
</RelativeLayout>

RelativeLayout为您提供可以添加到布局xml文件中的属性。

在您的情况下,您需要将其添加到线性布局中:

android:layout_alignParentBottom =“ true”

这将使容器与其父对象的底部对齐。

您可以在此处查看文档-http: //developer.android.com/guide/topics/ui/layout/relative.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM