RelativeLayout如何使两个元素底部对齐?

fabbymee 2021-05-26 04:26:49
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/ScreenRecordPage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
tools:context=".MainActivity">
<!-- If you want a button that has a custom background, you could switch the XML element in the layout to be <android.widget.Button> instead of <Button>. -->
<android.widget.Button
android:id="@+id/StartRecord"
android:layout_width="match_parent"
android:layout_height="50dp"
android:textAllCaps="false"
android:background="@drawable/start_record"
android:textSize="30sp"
android:textColor="@color/white"
android:layout_marginTop="8dp"
android:text="Start Record"/>

<RelativeLayout
android:layout_width="fill_parent"
android:layout_marginTop="15dp"
android:layout_height="50dp">
<TextView
android:id="@+id/myRecords"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Total Records"
android:layout_alignParentBottom="true"
android:textColor="@color/black"
android:textSize="20sp" />
</RelativeLayout>

<View
android:layout_marginTop="5dp"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/darker_gray"/>

<RelativeLayout
android:layout_width="fill_parent"
android:layout_marginTop="15dp"
android:layout_height="match_parent">
<ImageView
android:src="@drawable/screenshot"
android:layout_width="80dp"
android:layout_height="80dp"
android:id="@+id/screenShot"
android:layout_alignParentLeft="true"
android:layout_marginRight="10dp"
/>

<TextView
android:text="Video Name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:textSize="23dp"
android:textColor="#000000"
android:id="@+id/videoName"
android:layout_toRightOf="@id/screenShot"
android:layout_alignParentTop="true"
/>

<TextView
android:text="2021.05.19 · 5:11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:textSize="15dp"
android:textColor="#797675"
android:id="@+id/recordDate"
android:layout_toRightOf="@id/screenShot"
android:layout_below="@id/videoName"
/>

<TextView
android:text="6.4 MB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:textSize="15dp"
android:textColor="#797675"
android:id="@+id/videoSize"
android:layout_toRightOf="@id/screenShot"
android:layout_below="@id/recordDate"
android:layout_alignBottom="@id/screenShot"
/>
</RelativeLayout>
</LinearLayout>

如何使6.4MB跟图片底部对齐?

...全文
251 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
fabbymee 2021-05-26
  • 打赏
  • 举报
回复
android:layout_alignBottom="@id/screenShot" does not work Because You also have added android:layout_below="@id/recordDate" If You will remove this layout_below property then layout_alignBottom will work as expected. But when You will remove layout_below, then it may look strange. So You have to make changes according to that EDIT If You do not want to remove layout_below, then may be adding gravity to bottom will also work for You. As this will align the text to the bottom android:gravity="bottom"

80,349

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧