滚动视图内的RelativeLayout不滚动 [英] RelativeLayout inside scrollview doesn't scroll
本文介绍了滚动视图内的RelativeLayout不滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试将我的relativelayout用scrollview包裹起来,以在横向模式下使用,但它不起作用.我还尝试过用linearlayout包裹我的相对布局,但是它也不起作用.
I tried wrapping my relativelayout with scrollview to be used in landscape mode but it doesn't work. I also tried wrapping my relative layout with linearlayout but it doesn't work too.
这是将relativelayout包裹在滚动视图中的xml:
Here is the xml where relativelayout is wrapped in scrollview:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#2d89ef">
<!--Some components here-->
</RelativeLayout>
</ScrollView>
这是我完整的xml:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#2d89ef">
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="Segoe UI Light"
android:gravity="center"
android:text="@string/app_name"
android:textColor="#FFFFFF"
android:textSize="25dp"
android:textIsSelectable="false"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp" />
<EditText
android:id="@+id/editText"
android:layout_width="275dp"
android:layout_height="wrap_content"
android:ems="10"
android:fontFamily="Segoe UI Light"
android:gravity="center_vertical"
android:hint="@string/username"
android:inputType="textPersonName"
android:textColor="@android:color/white"
android:textSize="16sp"
android:width="200dp"
android:layout_below="@+id/textView"
android:layout_centerHorizontal="true">
<requestFocus />
</EditText>
<EditText
android:id="@+id/editText2"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:ems="10"
android:fontFamily="Segoe UI Light"
android:gravity="center_vertical"
android:hint="@string/password"
android:inputType="textPassword"
android:textColor="@android:color/white"
android:textSize="16sp"
android:width="200dp"
android:layout_below="@+id/editText"
android:layout_alignRight="@+id/editText"
android:layout_alignLeft="@+id/editText" />
<Button
android:id="@+id/button"
android:layout_width="250dp"
android:layout_height="40dp"
android:background="@drawable/border"
android:fontFamily="Segoe UI Light"
android:height="20dp"
android:text="@string/login"
android:textColor="#FFFFFF"
android:textSize="15sp"
android:width="200dp"
android:layout_marginTop="25dp"
android:layout_below="@+id/editText2"
android:layout_alignLeft="@+id/editText2"
android:layout_alignRight="@+id/editText2" />
<Button
android:id="@id/btnForgot"
android:layout_width="250dp"
android:layout_height="40dp"
android:background="@drawable/border"
android:fontFamily="Segoe UI Light"
android:height="20dp"
android:text="@string/forgot_password"
android:textColor="#FFFFFF"
android:textSize="15sp"
android:width="200dp"
android:layout_below="@+id/button"
android:layout_alignLeft="@+id/button"
android:layout_alignRight="@+id/button" />
<ImageView
android:layout_width="140dp"
android:layout_height="200dp"
android:id="@+id/imageView"
android:background="@drawable/auf_logo"
android:layout_above="@+id/textView"
android:layout_centerHorizontal="true" />
</RelativeLayout>
</ScrollView>
推荐答案
检查我下面的代码.它与您的布局相同.因此,只需将其更换并检查...
Check my below code.. It is same as your layout. So just replace it and check for it...
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#2d89ef"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/imageView"
android:layout_width="140dp"
android:layout_height="200dp"
android:layout_centerHorizontal="true"
android:background="@drawable/ic_launcher" />
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/imageView"
android:layout_centerVertical="true"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:fontFamily="Segoe UI Light"
android:gravity="center"
android:text="@string/app_name"
android:textColor="#FFFFFF"
android:textIsSelectable="false"
android:textSize="25dp" />
<EditText
android:id="@+id/editText"
android:layout_width="275dp"
android:layout_height="wrap_content"
android:layout_below="@+id/textView"
android:layout_centerHorizontal="true"
android:ems="10"
android:fontFamily="Segoe UI Light"
android:gravity="center_vertical"
android:inputType="textPersonName"
android:textColor="@android:color/white"
android:textSize="16sp"
android:width="200dp" >
<requestFocus />
</EditText>
<EditText
android:id="@+id/editText2"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/editText"
android:layout_alignRight="@+id/editText"
android:layout_below="@+id/editText"
android:ems="10"
android:fontFamily="Segoe UI Light"
android:gravity="center_vertical"
android:inputType="textPassword"
android:textColor="@android:color/white"
android:textSize="16sp"
android:width="200dp" />
<Button
android:id="@+id/button"
android:layout_width="250dp"
android:layout_height="40dp"
android:layout_alignLeft="@+id/editText2"
android:layout_alignRight="@+id/editText2"
android:layout_below="@+id/editText2"
android:layout_marginTop="25dp"
android:fontFamily="Segoe UI Light"
android:height="20dp"
android:text="Login"
android:textColor="#FFFFFF"
android:textSize="15sp"
android:width="200dp" />
<Button
android:id="@+id/btnForgot"
android:layout_width="250dp"
android:layout_height="40dp"
android:layout_alignLeft="@+id/button"
android:layout_alignRight="@+id/button"
android:layout_below="@+id/button"
android:fontFamily="Segoe UI Light"
android:height="20dp"
android:text="Forgot Password"
android:textColor="#FFFFFF"
android:textSize="15sp"
android:width="200dp" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
这篇关于滚动视图内的RelativeLayout不滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文