Android:将布局放在彼此之上

时间:2016-10-13 09:10:39

标签: android

我在重叠布局中遇到问题,我正在尝试在整个页面中实现登录表单,并在底部使用一个按钮,当用户按下此按钮时,注册表单从下向上滑动,我的问题是:第一个注册表单按下整个屏幕(我希望它溢出),第二个:我有2个按钮,形状背景显示在注册表单的顶部,登录输入仍然有效 我的xml代码

<?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:id="@+id/content_login_page"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/bg"
    tools:context="com.example.a3wd.mytest10.LoginPage"
    tools:showIn="@layout/activity_login_page">





            <ImageView
                android:id="@+id/login2Logo"
                android:layout_width="50dp"
                android:layout_height="70dp"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="50dp"
                android:contentDescription="@string/fixawy_logoPic"
                android:src="@drawable/logo2" />

            <LinearLayout
                android:id="@+id/loginInputs"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/login2Logo"
                android:layout_marginTop="30dp"
                android:orientation="vertical">

                <TextView
                    android:layout_width="140dp"
                    android:layout_height="30dp"
                    android:layout_gravity="center"
                    android:text="@string/loginText"
                    android:textColor="@color/loginText"
                    android:textSize="24sp"
                    android:textStyle="bold" />

                <EditText
                    android:id="@+id/userEmail"
                    android:layout_width="match_parent"
                    android:layout_height="50dp"
                    android:layout_marginEnd="50dp"
                    android:layout_marginLeft="50dp"
                    android:layout_marginRight="50dp"
                    android:layout_marginStart="50dp"
                    android:layout_marginTop="10dp"
                    android:background="@drawable/myspinner"
                    android:hint="@string/nameHint"
                    android:inputType="textEmailAddress"
                    android:padding="10dp" />

                <EditText
                    android:id="@+id/userPassword"
                    android:layout_width="match_parent"
                    android:layout_height="50dp"
                    android:layout_gravity="center"
                    android:layout_marginEnd="50dp"
                    android:layout_marginLeft="50dp"
                    android:layout_marginRight="50dp"
                    android:layout_marginStart="50dp"
                    android:layout_marginTop="8dp"
                    android:background="@drawable/myspinner"
                    android:hint="@string/passwordHint"
                    android:inputType="textPassword"
                    android:padding="10dp"
                    android:textAlignment="textEnd" />
            </LinearLayout>


            <Button
                android:id="@+id/loginBtn"
                android:layout_width="96dp"
                android:layout_height="56dp"
                android:layout_below="@id/loginInputs"
                android:layout_marginLeft="50dp"
                android:layout_marginTop="20dp"
                android:background="@drawable/shape_round_corner"
                android:text="@string/enterBtnTxt"

                />

            <TextView
                android:id="@+id/passwordText"
                android:layout_width="150dp"
                android:layout_height="30dp"
                android:layout_alignBaseline="@id/loginBtn"
                android:layout_alignParentRight="true"
                android:layout_below="@id/loginInputs"
                android:layout_marginRight="50dp"
                android:text="@string/forgetPassword"
                android:textColor="@color/loginText"
                android:textSize="20sp"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/facebookTxt"
                android:layout_width="200dp"
                android:layout_height="30dp"
                android:layout_below="@id/loginBtn"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="10dp"
                android:text="@string/facebookTxt"
                android:textSize="18sp" />

            <Button
                android:id="@+id/facebookBtn"
                android:layout_width="88dp"
                android:layout_height="32dp"
                android:layout_below="@id/facebookTxt"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="10dp"
                android:background="@drawable/facebookbtn"
                android:text="@string/facebook_btn"
                android:textColor="#ffffff" />
    <TextView
        android:id="@+id/newUserTxt"
        android:layout_width="140dp"
        android:layout_height="20dp"
        android:paddingEnd="10dp"
        android:paddingRight="10dp"
        android:text="@string/newUserTxt"
        android:textSize="18sp"
        android:layout_marginBottom="5dp"
        android:layout_alignParentRight="true"
        android:layout_above="@+id/registrationBtn"
        />

    <Button
        android:id="@id/registrationBtn"
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:background="@drawable/register_btn_shape"
        android:gravity="right"
        android:onClick="registerFragment"
        android:layout_alignParentBottom="true"
        android:paddingEnd="40dp"
        android:paddingRight="30dp"
        android:paddingTop="10dp"
        android:text="@string/registerTxt"
        android:textColor="#874f13"
        android:textSize="24sp"/>
    <LinearLayout
            android:id="@+id/registerForm"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
        android:layout_below="@id/newUserTxt"
            android:background="@drawable/register_back"
        android:orientation="vertical"
        android:visibility="invisible"
        >
<TextView
    android:layout_width="match_parent"
    android:layout_height="48dp"
    android:gravity="right"
    android:paddingEnd="40dp"
    android:paddingRight="40dp"
    android:paddingTop="10dp"
    android:text="@string/registerTxt"
    android:textColor="#874f13"
    android:textSize="24sp"
    />


    </LinearLayout>




</RelativeLayout>

和动画的java代码

 Animation bottomUp = AnimationUtils.loadAnimation(getApplicationContext(),
                    R.anim.bottom_up);
            registrationForm.startAnimation(bottomUp);
            registrationForm.setVisibility(View.VISIBLE);

这是原始视图before clicking the bottom btn 这是问题these 2 button suppose to be in the back view

的图像

0 个答案:

没有答案
相关问题