繁体   English   中英

另一个LinearLayout内部的Android LinearLayout

[英]Android LinearLayout Inside Another Linearlayout

我有两个带有圆角的线性布局,如下面的代码所示;

Im试图实现的是在linearlayout内部的linearlayout,但是顶部的外部布局边距会强制产生一个间隙,以便我可以输入文本。 内部看起来像内部布局具有黑色边框。

    <?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>

暂无
暂无

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

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