簡體   English   中英

無法使用ScrollView滾動線性布局?

[英]Not able to scroll my Linear Layout using ScrollView?

這是我用於顯示布局的XML文件。

edit_screen.xml

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/login_bg">
    <LinearLayout
        android:id="@+id/ll_userregisteration"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="25dp"
        android:layout_marginRight="25dp"
        android:layout_marginTop="30dp"
        android:isScrollContainer="true"
        android:gravity="center"
        android:orientation="vertical">
        <RelativeLayout
            android:layout_width="110dp"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp">
        <com.shout.networking.view.RoundedImageView
            android:id="@+id/profile_image"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:scaleType="center"
            android:src="@drawable/profile_placeholder"/>
            <ImageButton
                android:id="@+id/camera"
                android:layout_width="40dp"
                android:layout_height="40dp"
                android:layout_alignParentRight="true"
                android:layout_alignParentBottom="true"/>
        </RelativeLayout>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="What do we call you"
            android:textColor="@color/white"
            android:textSize="18sp" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <EditText
                android:id="@+id/et_reg_Fname"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginRight="2dp"
                android:textSize="16sp"
                android:layout_weight="1"
                android:backgroundTint="@color/white"
                android:hint="first name"
                android:textColor="@color/white"
                android:textColorHint="#7c7875" />

            <EditText
                android:id="@+id/et_reg_Lname"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="2dp"
                android:layout_weight="1"
                android:textSize="16sp"
                android:backgroundTint="@color/white"
                android:hint="last name"
                android:textColor="@color/white"
                android:textColorHint="#7c7875" />

        </LinearLayout>

        <RadioGroup
            android:id="@+id/radioGroup"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:orientation="horizontal">

            <RadioButton
                android:id="@+id/rb_male"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:button="@null"
                android:checked="true"
                android:drawableLeft="@drawable/selector_radio_button"
                android:drawablePadding="10dp"
                android:text="Male"
                android:textColor="@android:color/white"
                android:textSize="18sp" />

            <RadioButton
                android:id="@+id/rb_female"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:button="@null"
                android:checked="false"
                android:drawableLeft="@drawable/selector_radio_button"
                android:drawablePadding="10dp"
                android:text="Female"
                android:textColor="@android:color/white"
                android:textSize="18sp" />
        </RadioGroup>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:text="School of your cool"
            android:textColor="@color/white"
            android:textSize="18sp" />

        <EditText
            android:id="@+id/et_university"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:backgroundTint="@color/white"
            android:textSize="14sp"
            android:hint="add your university"
            android:textColor="@color/white"
            android:textColorHint="#7c7875" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:text="what you call home"
            android:textColor="@color/white"
            android:textSize="18sp" />

        <EditText
            android:id="@+id/et_livingaddress"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:backgroundTint="@color/white"
            android:hint="Where do you live now"
            android:textColor="@color/white"
            android:textSize="16sp"
            android:textColorHint="#7c7875" />

        <EditText
            android:id="@+id/et_permanentaddress"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:backgroundTint="@color/white"
            android:hint="Where do you belong to"
            android:textSize="16sp"
            android:textColor="@color/white"
            android:textColorHint="#7c7875" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:text="Whats Your Calling"
            android:textColor="@color/white"
            android:textSize="18sp" />

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <EditText
                android:id="@+id/et_interset"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:backgroundTint="@color/white"
                android:layout_toLeftOf="@+id/sp_interset"
                android:hint="Type in your calling/pick from the list"
                android:textSize="16sp"
                android:maxLength="30"
                android:textColor="@color/white"
                android:textColorHint="#7c7875"
                android:maxLines="1" />

            <Spinner
                android:id="@+id/sp_interset"
                android:layout_width="20dp"
                android:layout_height="20dp"
                android:layout_alignParentRight="true"
                android:layout_marginRight="5dp"
                android:layout_centerVertical="true"
                android:background="@drawable/down_thicker"
                android:dropDownWidth="250dp"
                android:backgroundTint="@android:color/white"
                android:popupBackground="#4b4b49"
                android:spinnerMode="dropdown" />
        </RelativeLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:weightSum="2"
            android:layout_marginTop="10dp">
        <Button
            android:id="@+id/btn_cancel"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:background="@drawable/selector_signup_button"
            android:text="CANCEL"
            android:layout_marginRight="20dp"
            android:textColor="@color/black"
            android:layout_weight="1"
            android:textSize="15sp" />

            <Button
                android:id="@+id/btn_save"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:background="@drawable/selector_signup_button"
                android:text="SAVE"
                android:textColor="@color/black"
                android:layout_weight="1"
                android:textSize="15sp" />

        </LinearLayout>

    </LinearLayout>
</ScrollView>

這是我的布局的屏幕截圖。我無法滾動它。

屏幕截圖

我已經將Linear LAyout放入ScrollView中,但是我也無法在xml設計中獲得滾動功能。

將LinearLayout的高度更改為match_parent。 它會工作。

ScrollView嘗試添加以下行:

app:layout_behavior="@string/appbar_scrolling_view_behavior"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM