How to make Button overlap CardView at the bottom

前端 未结 7 1767
慢半拍i
慢半拍i 2020-12-29 00:33

I am creating an app that displays announcements, and I want to add a login. I am trying to make this XML design,

相关标签:
7条回答
  • 2020-12-29 01:21
    <?xml version="1.0" encoding="utf-8"?>
    <android.support.design.widget.CoordinatorLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:card_view="http://schemas.android.com/apk/res-auto"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
        <LinearLayout android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical">
            <LinearLayout android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:background="@drawable/background_login"
                        android:layout_weight="1"
            android:layout_marginBottom="@dimen/margin_large"></LinearLayout>
    
            <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:orientation="vertical"
                    android:layout_marginTop="-60dp"
                    android:layout_weight="1"
            >
    
    
                <android.support.v7.widget.CardView
                        android:id="@+id/card_view"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_marginLeft="@dimen/margin_large"
                        android:layout_marginRight="@dimen/margin_large"
                        android:layout_marginBottom="30dp"
                        android:background="@android:color/white"
                        card_view:cardCornerRadius="@dimen/margin_card_medium"
                        card_view:cardElevation="@dimen/margin_card_medium">
    
                    <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:orientation="vertical"
                            android:padding="@dimen/margin_medium_2">
    
                        <TextView android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:text="@string/login"
                                android:gravity="center"
                                android:textSize="@dimen/text_regular_3x"
                                android:textColor="@color/secondaryText"/>
    
                        <TextView android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:text="@string/email"
                                android:textSize="@dimen/text_small"
                                android:textColor="@color/colorBlue"
                                android:layout_marginTop="@dimen/margin_medium"/>
    
                        <EditText
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:id="@+id/ed_email"
                                android:textSize="@dimen/text_regular"
                                android:inputType="textEmailAddress"/>
    
                        <TextView android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:textSize="@dimen/text_small"
                                android:text="@string/password"
                                android:textColor="@color/colorBlue"
                                android:layout_marginTop="@dimen/margin_large"/>
    
                        <EditText
                                android:id="@+id/ed_password"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:textSize="@dimen/text_regular"
                                android:inputType="textPassword"/>
    
    
    
                            <CheckBox
                                    android:layout_width="match_parent"
                                    android:layout_height="wrap_content"
                                    android:text="@string/show_password"
                                    android:textSize="@dimen/text_small"
                                    android:textColor="@color/secondaryText"
                                    android:buttonTint="@color/secondaryText"
                                    android:checked="true"
                            />
    
    
                    </LinearLayout>
    
                </android.support.v7.widget.CardView>
    
            </RelativeLayout>
            <Button
            android:layout_width="200dp"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_gravity="center"
            android:layout_marginTop="-55dp"
            android:elevation="15dp"
            android:text="Log In"
            android:textColor="@color/colorWhite"
            android:layout_alignParentBottom="true"
            android:background="@drawable/shapesignup"
    
            />
    
        </LinearLayout>
        <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|center"
        android:text="FORGOT PASSWORD?"
        android:layout_centerHorizontal="true"
        android:layout_alignParentBottom="true"
        android:textColor="@color/secondaryText"
        android:textSize="@dimen/text_small"
        android:layout_margin="@dimen/margin_large"
        />
    </android.support.design.widget.CoordinatorLayout>    
    

    OutPut

    Here background_login

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android">
        <gradient
                android:angle="225"
                android:startColor="@color/colorBlue"
                android:endColor="#21d6d3" />
    </shape>
    
    0 讨论(0)
提交回复
热议问题