滚动型不起作用 [英] ScrollView doesn't work
问题描述
这应该很容易,我知道!我看了教程,搜索约。 2小时,试图像15不同的方法(可能更多),但仍无法得到它的工作。
在我的应用程序时,我重点/选择的EditText和键盘弹出我不能向下滚动到输入其他文字
的AndroidManifest.xml > 活动设置为的android:windowSoftInputMode =adjustPan
下面是在布局> main.xml中
<?XML版本=1.0编码=UTF-8&GT?;
<滚动型的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =match_parent
机器人:layout_height =match_parent><的LinearLayout
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:背景=@绘制/ BG
机器人:方向=垂直
机器人:填充=20dp> <的LinearLayout
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginTop =10dp> <的TextView
机器人:ID =@ + ID / txtProduct1
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:文字=1 PRODUKT
机器人:文字颜色=#FFFFFF
机器人:TEXTSIZE =28dp
机器人:文字样式=大胆/> <的TextView
机器人:ID =@ + ID / txtInfo1
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =FILL_PARENT
机器人:layout_marginLeft =5DP
机器人:重力=右
机器人:文字=以上的价格/ hmot:0 EUR
机器人:textAppearance =机器人:ATTR / textAppearanceSmall
机器人:文字颜色=#EEEEEE
机器人:宽=140dp/>
< / LinearLayout中> <的EditText
机器人:ID =@ + ID / txtPrice1
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginBottom =5DP
机器人:layout_marginTop =10dp
机器人:EMS =10
机器人:提示=以上的价格
安卓的inputType =numberDecimal>
< /&的EditText GT; <的EditText
机器人:ID =@ + ID / txtWeight1
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginBottom =20dp
机器人:EMS =10
机器人:提示=Hmotnosť
安卓的inputType =numberDecimal/> < ImageView的
机器人:ID =@ + ID / imgResult
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_gravity =CENTER_HORIZONTAL
机器人:SRC =@绘制/问题/> <的EditText
机器人:ID =@ + ID / txtPrice2
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginBottom =5DP
机器人:layout_marginTop =20dp
机器人:EMS =10
机器人:提示=以上的价格
安卓的inputType =numberDecimal/> <的EditText
机器人:ID =@ + ID / txtWeight2
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginBottom =5DP
机器人:EMS =10
机器人:提示=Hmotnosť
安卓的inputType =numberDecimal/> <的LinearLayout
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT> <的TextView
机器人:ID =@ + ID / txtInfo2
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =FILL_PARENT
机器人:layout_marginRight =5DP
机器人:文字=以上的价格/ hmot:0 EUR
机器人:textAppearance =机器人:ATTR / textAppearanceSmall
机器人:文字颜色=#EEEEEE
机器人:宽=140dp/> <的TextView
机器人:ID =@ + ID / txtProduct2
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:文字=PRODUKT 2
机器人:文字颜色=#FFFFFF
机器人:TEXTSIZE =28dp
机器人:文字样式=大胆/>
< / LinearLayout中> <按钮
机器人:ID =@ + ID / btnOK
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_gravity =CENTER_HORIZONTAL
机器人:layout_marginTop =15dp
机器人:身高=80dp
机器人:文字=OK
机器人:文字颜色=#264865
机器人:TEXTSIZE =24dp
机器人:文字样式=大胆
机器人:宽=160dp/>
< / LinearLayout中>< /滚动型>
东西夫妇:
-
确保滚动型只有一个孩子,
-
前面已经提到,要确保你有一个结束标记
-
以下code为我工作...
<?XML版本=1.0编码=UTF-8&GT?;<滚动型的xmlns:机器人=http://schemas.android.com/apk/res/android 机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:fillViewport =真正的> <的LinearLayout
机器人:方向=垂直
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT> <! - 我增加了更多的意见在这里! - > < / LinearLayout中>
< /滚动型>
块引用>希望这有助于。
----------------------------------------------- -------------------------------------------
从评论...更新的时候我截图复制并粘贴您的code(在三星Galaxy S)。工作!
It should be easy I know!!! I watched tutorial, searched for approx. 2 hours and tried like 15 different methods (maybe more) and still can't get it to work.
In my app when I focus/select EditText and keyboard pops out I can't scroll down to input other text
AndroidManifest.xml > activity set to android:windowSoftInputMode="adjustPan"
here is the layout>main.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" > <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/bg" android:orientation="vertical" android:padding="20dp" > <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="10dp" > <TextView android:id="@+id/txtProduct1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Produkt 1" android:textColor="#FFFFFF" android:textSize="28dp" android:textStyle="bold" /> <TextView android:id="@+id/txtInfo1" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_marginLeft="5dp" android:gravity="right" android:text="cena / hmot: 0 eur" android:textAppearance="?android:attr/textAppearanceSmall" android:textColor="#EEEEEE" android:width="140dp" /> </LinearLayout> <EditText android:id="@+id/txtPrice1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="5dp" android:layout_marginTop="10dp" android:ems="10" android:hint="Cena" android:inputType="numberDecimal" > </EditText> <EditText android:id="@+id/txtWeight1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="20dp" android:ems="10" android:hint="Hmotnosť" android:inputType="numberDecimal" /> <ImageView android:id="@+id/imgResult" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:src="@drawable/question" /> <EditText android:id="@+id/txtPrice2" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="5dp" android:layout_marginTop="20dp" android:ems="10" android:hint="Cena" android:inputType="numberDecimal" /> <EditText android:id="@+id/txtWeight2" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="5dp" android:ems="10" android:hint="Hmotnosť" android:inputType="numberDecimal" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" > <TextView android:id="@+id/txtInfo2" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_marginRight="5dp" android:text="cena / hmot: 0 eur" android:textAppearance="?android:attr/textAppearanceSmall" android:textColor="#EEEEEE" android:width="140dp" /> <TextView android:id="@+id/txtProduct2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Produkt 2" android:textColor="#FFFFFF" android:textSize="28dp" android:textStyle="bold" /> </LinearLayout> <Button android:id="@+id/btnOK" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:layout_marginTop="15dp" android:height="80dp" android:text="OK" android:textColor="#264865" android:textSize="24dp" android:textStyle="bold" android:width="160dp" /> </LinearLayout> </ScrollView>
解决方案Couple of things:
Make sure the ScrollView only has one child,
As already mentioned, make sure you have a closing tag
The following code worked for me...
<?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:fillViewport="true" > <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <!--I added more views here! --> </LinearLayout> </ScrollView>
Hope this helps.
------------------------------------------------------------------------------------------
Update from comments... Screenshot of when I copy and pasted your code (on a Samsung Galaxy S). Working!
这篇关于滚动型不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!