我有两个带有圆角的线性布局,如下面的代码所示;
我试图实现的是线性布局中的线性布局,但顶部的外部布局边距强制产生间隙,以便我可以输入文本。在内部看起来内部布局有一个深色边框。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/loginbackground" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="62dp"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="5dip"
android:background="@drawable/rounded_rectangle_dark"
android:orientation="vertical"
>
<!-- TextView goes here -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dip"
android:background="@drawable/rounded_rectangle_white"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/imageView2"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:scaleType="fitCenter"
android:src="@drawable/icon_contact" />
<EditText
android:id="@+id/login_username_edittext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:layout_weight="1"
android:hint="@string/login_username_hint"
android:inputType="textEmailAddress"
android:text="pandulce@email.com" >
<!-- <requestFocus />-->
</EditText>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<!-- End of Inner Layout -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:layout_marginTop="10dp"
android:orientation="vertical" >
<Button
android:id="@+id/login_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/red_button"
android:textStyle="bold"
android:textSize="25sp"
android:text="@string/login_login_btn"
android:textColor="@color/solid_white" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
这是颜色样式;
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<solid android:color="#ffffff"/>
<stroke android:width="1dp"
android:color="#2B3856"/>
<corners android:radius="20dp"/>
</shape>
任何帮助,不胜感激。
我不清楚你真正想要的是什么。无论如何都在寻找类似
的东西这?
编辑:
下面是 XML 布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="62dp"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="5dip"
android:background="@drawable/rounded_rectangle_dark"
android:orientation="vertical" >
<!-- TextView goes here -->
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:text="TextView"
android:textColor="#FFFFFF" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dip"
android:background="@drawable/rounded_rectangle_white"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/imageView2"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:scaleType="fitCenter" />
<EditText
android:id="@+id/login_username_edittext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:layout_weight="1"
android:inputType="textEmailAddress"
android:text="pandulce@email.com" >
<!-- <requestFocus /> -->
</EditText>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<!-- End of Inner Layout -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:layout_marginTop="10dp"
android:orientation="vertical" >
<Button
android:id="@+id/login_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/red_button"
android:textSize="25sp"
android:textStyle="bold"
android:text="Log in"
android:textColor="#FFFFFF" />
</LinearLayout>
</LinearLayout>