After adding a ScrollView, the the app title is no longer displayed

前端 未结 1 616
广开言路
广开言路 2021-01-22 17:34

Hi in the below code i have a login layout in that contains email id and password are the attributes.

Now want to display my layout in landscape mode.because of that i j

相关标签:
1条回答
  • 2021-01-22 18:17

    Your title is not displaying because the height of your ScrollView is match_parent

    So your RelativeLayout is hiding behind ScrollView

    Just add android:layout_below="@id/toolbarRel" in your ScrollView

    SAMPLE CODE

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#1c1c1c">
    
        <RelativeLayout
            android:id="@+id/toolbarRel"
            android:layout_width="match_parent"
            android:layout_height="@dimen/toolbar_height"
            android:layout_alignParentTop="true"
            android:layout_gravity="center_vertical"
            android:background="@color/color_toolbar">
    
            <RelativeLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:layout_centerVertical="true"
                android:layout_gravity="center_horizontal">
    
                <TextView
                    android:id="@+id/text_title"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/login"
                    android:textColor="@color/white"
                    android:textSize="@dimen/heading_font_size"
                    android:textStyle="bold" />
            </RelativeLayout>
        </RelativeLayout>
    
        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@id/toolbarRel"
            android:background="#1c1c1c"
            android:fillViewport="false">
    
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/toolbarRel"
                android:layout_centerInParent="true"
                android:layout_marginTop="20dp"
                android:gravity="center_vertical|center_horizontal"
                android:orientation="vertical"
                android:paddingStart="@dimen/activity_horizontal_margin"
                android:paddingEnd="@dimen/activity_horizontal_margin">
    
                <EditText
                    android:id="@+id/et_email"
                    style="@style/common_text"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="@drawable/textfield_outer_box"
                    android:drawableStart="@drawable/img_email_icon"
                    android:drawableLeft="@drawable/img_email_icon"
                    android:drawablePadding="10dp"
                    android:ems="10"
                    android:hint="Email Id"
                    android:inputType="textEmailAddress"
                    android:paddingStart="10dp"
                    android:paddingEnd="10dp" />
    
                <EditText
                    android:id="@+id/et_pwd"
                    style="@style/common_text"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/homogeneous_margin"
                    android:background="@drawable/textfield_outer_box"
                    android:drawableStart="@drawable/img_password_icon"
                    android:drawableLeft="@drawable/img_password_icon"
                    android:drawablePadding="10dp"
                    android:ems="10"
                    android:hint="Password"
                    android:inputType="textPassword"
                    android:paddingStart="10dp"
                    android:paddingEnd="10dp" />
    
                <Button
                    android:id="@+id/btn_login"
                    style="@style/style_button"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/heterogenous_margin"
                    android:background="@drawable/login_button"
                    android:paddingBottom="@dimen/button_topbottom_padding"
                    android:text="@string/get_started" />
    
                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/homogeneous_margin">
    
                    <TextView
                        android:id="@+id/txt_forgot_password"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="13dp"
                        android:gravity="center_vertical"
                        android:text="Forgot Password?"
                        android:textColor="@android:color/white"
                        android:textSize="18sp" />
    
                    <TextView
                        android:id="@+id/text_create_account"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentEnd="true"
                        android:layout_alignParentRight="true"
                        android:layout_marginTop="@dimen/homogeneous_margin"
                        android:gravity="center"
                        android:text="Create Account"
                        android:textColor="@android:color/white"
                        android:textSize="18sp" />
                </RelativeLayout>
    
                <TextView
                    style="@style/common_text"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="13dp"
                    android:text="or sign with"
                    android:visibility="gone" />
            </LinearLayout>
        </ScrollView>
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:orientation="horizontal"
            android:visibility="visible"
            android:weightSum="2">
    
            <!--<com.facebook.login.widget.LoginButton-->
            <!--android:id="@+id/login_button"-->
            <!--android:layout_width="0dp"-->
            <!--android:layout_height="wrap_content"-->
            <!--android:layout_gravity="center_vertical"-->
            <!--android:layout_marginBottom="8dp"-->
            <!--android:layout_marginLeft="8dp"-->
            <!--android:layout_margin="4dp"-->
            <!--android:layout_paddinBottom="12dp"-->
            <!--android:layout_paddingTop="12dp"-->
            <!--android:gravity="center"-->
            <!--android:layout_weight="1"-->
            <!--/>-->
            <!--<com.google.android.gms.common.SignInButton-->
            <!--android:id="@+id/signin_button"-->
            <!--android:layout_width="0dp"-->
            <!--android:layout_height="wrap_content"-->
            <!--android:layout_centerInParent="true"-->
            <!--android:layout_weight="1"/>-->
    
    
        </LinearLayout>
    </RelativeLayout>
    

    UPDATE

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#1c1c1c">
    
        <RelativeLayout
            android:id="@+id/toolbarRel"
            android:layout_width="match_parent"
            android:layout_height="?actionBarSize"
            android:layout_alignParentTop="true"
            android:layout_gravity="center_vertical">
    
            <RelativeLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:layout_centerVertical="true"
                android:layout_gravity="center_horizontal">
    
                <TextView
                    android:id="@+id/text_title"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Login"
                    android:textColor="@android:color/white"
                    android:textStyle="bold" />
            </RelativeLayout>
        </RelativeLayout>
    
        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@id/toolbarRel"
            android:layout_centerInParent="true"
            android:background="#1c1c1c"
            android:fillViewport="false">
    
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="20dp"
                android:gravity="center_vertical|center_horizontal"
                android:orientation="vertical"
                android:paddingStart="@dimen/activity_horizontal_margin"
                android:paddingEnd="@dimen/activity_horizontal_margin">
    
                <EditText
                    android:id="@+id/et_email"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:drawablePadding="10dp"
                    android:ems="10"
                    android:hint="Email Id"
                    android:inputType="textEmailAddress"
                    android:paddingStart="10dp"
                    android:paddingEnd="10dp" />
    
                <EditText
                    android:id="@+id/et_pwd"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:drawablePadding="10dp"
                    android:ems="10"
                    android:hint="Password"
                    android:inputType="textPassword"
                    android:paddingStart="10dp"
                    android:paddingEnd="10dp" />
    
                <Button
                    android:id="@+id/btn_login"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="get_started" />
    
                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">
    
                    <TextView
                        android:id="@+id/txt_forgot_password"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="13dp"
                        android:gravity="center_vertical"
                        android:text="Forgot Password?"
                        android:textColor="@android:color/white"
                        android:textSize="18sp" />
    
                    <TextView
                        android:id="@+id/text_create_account"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentEnd="true"
                        android:layout_alignParentRight="true"
                        android:gravity="center"
                        android:text="Create Account"
                        android:textColor="@android:color/white"
                        android:textSize="18sp" />
                </RelativeLayout>
    
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="13dp"
                    android:text="or sign with"
                    android:visibility="gone" />
            </LinearLayout>
        </ScrollView>
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:orientation="horizontal"
            android:visibility="visible"
            android:weightSum="2">
    
    
        </LinearLayout>
    </RelativeLayout>
    
    0 讨论(0)
提交回复
热议问题