【发布时间】:2021-09-20 20:09:07
【问题描述】:
如何创建一个布局,其中两个按钮可以从左侧填充一半的布局,第二个按钮在右侧,下面还有一个视图作为边框?
我的布局
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary"
tools:context=".Login">
<RelativeLayout
android:gravity="center_horizontal"
android:layout_marginTop="70dp"
android:layout_marginBottom="70dp"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:background="@color/white"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="@dimen/_45sdp"
android:background="@color/white"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/btn_chat"
android:layout_alignParentLeft="true"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@color/white"
android:textColor="@color/colorPrimary"
android:textStyle="bold"
android:text="LOGIN" />
<Button
android:id="@+id/btn_cart"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@color/white"
android:textColor="@color/lightDark"
android:textStyle="bold"
android:text="REGISTER" />
</RelativeLayout>
<View
android:id="@+id/active_border"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:background="@color/colorPrimary"
android:layout_width="wrap_content"
android:layout_height="1dp"/>
<View
android:id="@+id/inactive_border"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:background="@color/lightDark"
android:layout_width="wrap_content"
android:layout_height="1dp"/>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
【问题讨论】:
标签: android android-layout layout