代码之家  ›  专栏  ›  技术社区  ›  victorldavila

NestedScrollView内的内容布局xml双高大小

  •  0
  • victorldavila  · 技术社区  · 8 年前

    我有一个活动xml中的Coordinator布局和一个包含内容布局xml的include布局。这样地:

    <android.support.design.widget.CoordinatorLayout 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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:id="@+id/main">
    
    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    
    <include layout="@layout/content_sign_in" />
    
    </android.support.v4.widget.NestedScrollView>
    

    当我把我的内容布局放在一个嵌套滚动视图中时,我的内容版式会加倍你的高度。有人能帮我吗?

    <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_sign_in"
    android:layout_width="match_parent"
    android:background="@drawable/sign_up_bg"
    android:layout_height="match_parent"
    tools:showIn="@layout/activity_sign_in">
    
    <ImageButton
        android:id="@+id/arrow_back"
        android:layout_marginTop="15dp"
        android:layout_marginLeft="10dp"
        android:scaleType="centerInside"
        android:padding="5dp"
        android:src="@drawable/ic_back_white"
        android:background="@android:color/transparent"
        android:layout_width="40dp"
        android:layout_height="40dp" />
    
    <ImageView
        android:scaleType="centerInside"
        android:layout_below="@+id/arrow_back"
        android:id="@+id/logo"
        android:layout_marginTop="6dp"
        android:layout_centerHorizontal="true"
        android:layout_width="78dp"
        android:layout_height="45dp" />
    
    <android.support.design.widget.TextInputLayout
        android:textColorHint="@color/color_80ffffff"
        android:id="@+id/input_layout_email"
        android:layout_marginLeft="46dp"
        android:hint=" "
        android:layout_marginRight="46dp"
        android:layout_marginTop="74dp"
        android:layout_below="@+id/logo"
        app:errorTextAppearance="@style/error_appearance"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    
    <android.support.v7.widget.AppCompatEditText
        android:id="@+id/work_email"
        android:gravity="center"
        android:theme="@style/EditTextLogin"
        android:textColorHint="@color/color_80ffffff"
        android:hint="@string/hint_work_email"
        android:textColor="@android:color/white"
        android:textSize="14sp"
        android:inputType="textEmailAddress"
        android:imeOptions="actionNext"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
    
    </android.support.design.widget.TextInputLayout>
    
    <android.support.design.widget.TextInputLayout
        android:textColorHint="@color/color_80ffffff"
        android:id="@+id/input_layout_password"
        android:layout_marginLeft="46dp"
        android:hint=" "
        android:theme="@style/EditTextLogin"
        android:layout_marginRight="46dp"
        android:layout_below="@+id/input_layout_email"
        app:errorTextAppearance="@style/error_appearance"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    
        <android.support.v7.widget.AppCompatEditText
            android:id="@+id/password"
            android:gravity="center"
            android:textColorHint="@color/color_80ffffff"
            android:hint="@string/hint_password"
            android:textColor="@android:color/white"
            android:textSize="14sp"
            android:inputType="textPassword"
            android:imeOptions="actionDone"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    
    </android.support.design.widget.TextInputLayout>
    
    <Button
        android:layout_below="@+id/input_layout_password"
        android:id="@+id/btn_sign_in"
        android:textColor="@android:color/white"
        android:text="@string/btn_login"
        android:layout_marginTop="26dp"
        android:background="@color/colorAccent"
        android:layout_marginRight="60dp"
        android:layout_marginLeft="60dp"
        android:layout_width="match_parent"
        android:layout_height="40dp" />
    
    <RelativeLayout
        android:layout_marginTop="17dp"
        android:layout_below="@+id/btn_sign_in"
        android:gravity="center"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    
        <TextView
            android:id="@+id/label_sign_up"
            android:textSize="14sp"
            android:text="@string/lbl_sign_up"
            android:textColor="@color/color_80ffffff"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    
        <TextView
            android:layout_toRightOf="@+id/label_sign_up"
            android:textStyle="bold"
            android:layout_marginLeft="5dp"
            android:id="@+id/btn_sign_up"
            android:textSize="14sp"
            android:text="@string/txt_sign_up"
            android:textColor="@android:color/white"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    
    </RelativeLayout>
    
    <TextView
        android:id="@+id/forgot_password"
        android:textColor="@color/color_80ffffff"
        android:textSize="14sp"
        android:gravity="center"
        android:text="@string/text_forgot_password"
        android:layout_marginBottom="20dp"
        android:layout_alignParentBottom="true"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
    
    <RelativeLayout
        android:visibility="gone"
        android:id="@+id/layout_resend"
        android:layout_alignParentBottom="true"
        android:layout_width="match_parent"
        android:layout_height="86dp">
    
        <ImageView
            android:scaleType="fitXY"
            android:src="@drawable/pink_bar"
            android:layout_width="match_parent"
            android:layout_height="86dp" />
    
        <Button
            android:id="@+id/btn_resend"
            android:layout_marginRight="10dp"
            android:layout_alignParentRight="true"
            android:layout_marginTop="26dp"
            android:textSize="14sp"
            android:text="@string/txt_resend"
            android:textColor="@color/color_505065"
            android:background="@android:color/transparent"
            android:layout_width="wrap_content"
            android:layout_height="40dp" />
    
        <ImageView
            android:id="@+id/ic_email"
            android:layout_marginLeft="16dp"
            android:layout_marginTop="26dp"
            android:src="@drawable/ic_email_confirmation_white"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    
        <TextView
            android:layout_marginLeft="15dp"
            android:layout_toRightOf="@+id/ic_email"
            android:layout_toLeftOf="@+id/btn_resend"
            android:layout_marginTop="26dp"
            android:textSize="14sp"
            android:text="@string/text_resend_email"
            android:textColor="@android:color/white"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    
    </RelativeLayout>
    
    <RelativeLayout
        android:visibility="gone"
        android:id="@+id/load"
        android:background="#aa000000"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <ProgressBar
            android:layout_centerVertical="true"
            android:layout_centerHorizontal="true"
            android:layout_width="50dp"
            android:layout_height="50dp" />
    </RelativeLayout>
    

    我不知道为什么会这样

    1 回复  |  直到 8 年前
        1
  •  0
  •   Felipe Ribeiro R. Magalhaes    8 年前

    我认为你的布局层次结构没有任何问题。事情可能有点奇怪,因为您使用图像作为背景,没有固定的高度和宽度。我不知道这是XML背景还是图像文件,但如果是后者,我建议在相对布局中使用图像视图,并定义固定大小和比例类型。