我使用此代码来制作此布局。为什么在这个布局中有一些空间?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:background="@android:color/transparent">
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_centerInParent="true"
android:background="@drawable/rounded_white_bg">
<EditText
android:id="@+id/login"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:background="@drawable/dialog_edittex"
android:layout_margin="10dp"/>
<EditText
android:id="@+id/password"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_margin="10dp"
android:background="@drawable/dialog_edittex"/>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textColor="@android:color/black"
android:text="AAAAAAAAAAAA"
android:layout_gravity="center"
android:textSize="20sp"
/>
<ImageView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:src="@drawable/dialog_button_bg"/>
</LinearLayout>
</RelativeLayout>
rouded_whiite.bg.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#ffffff" />
<corners
android:radius="20dp"/>
</shape>
但我做到这一点时,我有看到这样的结果。正如你所看到的,红色按钮下方有一些余量。我没有设置任何保证金或其他东西,但在那里有一些空间。我应该在这里做什么来获得像第一拳那样精确的结果。
android:layout_margin =“20dp”? –
你有没有试过在你的'LinearLayout'和'RelativeLayout'中设置android:padding =“0dp”? – Fllo
如果你只能使用RelativeLayout来实现它,你为什么要使用嵌套的线性布局? – r4jiv007