Android 滚动视图工作不正常
我正在尝试制作一个滚动视图。我的应用程序中有一个文本字段,当我打开键盘时,整个屏幕会向上移动,我想让它滚动,这样我就可以看到上面发生了什么 我的滚动视图有一个文本字段和一些图像视图显示在屏幕上Android 滚动视图工作不正常,android,android-layout,android-scrollview,Android,Android Layout,Android Scrollview,我正在尝试制作一个滚动视图。我的应用程序中有一个文本字段,当我打开键盘时,整个屏幕会向上移动,我想让它滚动,这样我就可以看到上面发生了什么 我的滚动视图有一个文本字段和一些图像视图显示在屏幕上 <ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent" android:scrollbars="vertical" android:fillViewport
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="vertical"
android:fillViewport="true"
android:id="@+id/scrollView2" >
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:minHeight="570dp">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="60dp"
android:layout_marginTop="30dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Total Lives :"
android:id="@+id/textView12"
android:layout_marginTop="8dp"
android:layout_marginLeft="20dp" />
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:id="@+id/lifeImage1"
android:src="@drawable/full_brain_game" />
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:id="@+id/lifeImage2"
android:src="@drawable/full_brain_game" />
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:id="@+id/lifeImage3"
android:src="@drawable/full_brain_game" />
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:id="@+id/lifeImage4"
android:src="@drawable/full_brain_game" />
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:id="@+id/lifeImage5"
android:src="@drawable/full_brain_game" />
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:id="@+id/lifeImage6"
android:src="@drawable/full_brain_game" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="@+id/textView7"
android:layout_marginLeft="150dp"
android:textColor="@color/red"
android:layout_marginTop="150dp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView"
android:src="@drawable/full_brain_game_1" />
</LinearLayout>
</ScrollView>
首先,您需要将滚动视图的高度和宽度设置为匹配父项
,然后线性布局的高度也必须是匹配父项
。然后一切都会好起来。首先,您需要将滚动视图的高度和宽度设置为匹配父项
,然后线性布局的高度也必须是匹配父项
。然后一切都会好起来。将ScrollView子对象更改为RelativeLayout,如下所示,并在RelativeLayout中添加线性布局:
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</RelativeLayout>
将ScrollView子对象更改为RelativeLayout,如下所示,并在RelativeLayout中添加线性布局:
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</RelativeLayout>
尝试此操作,并继续在线性布局中添加视图。
试试这个,然后继续在线性布局中添加视图。它们都不适合我。如果有人知道的话,还有别的解决办法吗?没有一个对我有用。如果有人知道,还有其他解决方案吗?