[英]Android scrollview doesn't work - 1 main child linear layout
This is my code: 1 child, other relative layout elements are nested inside main one, so it makes 1 child for scroll view. 这是我的代码:1个孩子,其他相对布局元素嵌套在主要对象中,因此它使1个孩子成为滚动视图。
I am creating this for Nexus 7, but when I check it inside my HTC Desire HD scroll view doesn't work, it just cuts last "RelativeLayoutGerman". 我是为Nexus 7创建的,但是当我在HTC Desire HD滚动视图中检查它时,它只会剪切最后的“ RelativeLayoutGerman”。
Any ideas? 有任何想法吗?
Code: 码:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mainScroll"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >
<RelativeLayout
android:id="@+id/relativeLayoutMain"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/backrepeat"
android:gravity="clip_vertical"
tools:context=".MainActivity" >
<RelativeLayout
android:id="@+id/relativeLayoutMainHeader"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="@drawable/bghead"
android:orientation="vertical" >
</RelativeLayout>
<RelativeLayout
android:id="@+id/relativeLayoutMainGerman"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/relativeLayoutMainSlovenscina"
android:orientation="vertical" >
<TextView
android:id="@+id/textViewMainGerman"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/imageViewMainLine3"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:text="@string/mainGerman"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#9B7D66" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/relativeLayoutMainSlovenscina"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/relativeLayoutMainEnglish"
android:orientation="vertical" >
<TextView
android:id="@+id/textViewCategoriesDrinks"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginBottom="20dp"
android:layout_marginTop="20dp"
android:text="@string/mainSlovene"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#9B7D66" />
<ImageView
android:id="@+id/imageViewMainLine1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/imageViewTopLine2"
android:layout_centerHorizontal="true"
android:contentDescription="@string/descrLine"
android:src="@drawable/middleline" />
<ImageView
android:id="@+id/imageViewTopLine2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/textViewCategoriesDrinks"
android:layout_centerHorizontal="true"
android:contentDescription="@string/descrLine"
android:src="@drawable/line_top" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/relativeLayoutMainEnglish"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/relativeLayoutMainHeader"
android:layout_marginTop="20dp"
android:clickable="true"
android:onClick="selectEnglish"
android:orientation="vertical" >
<TextView
android:id="@+id/textViewMainEnglish"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/relativeLayoutMainHeader"
android:layout_centerHorizontal="true"
android:layout_marginBottom="20dp"
android:layout_marginTop="20dp"
android:text="@string/mainEnglish"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#9B7D66" />
<ImageView
android:id="@+id/imageViewMainLine3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/imageViewTopLine1"
android:layout_centerHorizontal="true"
android:src="@drawable/middleline" />
<ImageView
android:id="@+id/imageViewTopLine1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/textViewMainEnglish"
android:layout_centerHorizontal="true"
android:contentDescription="@string/descrLine"
android:src="@drawable/line_top" />
</RelativeLayout>
</RelativeLayout>
</ScrollView>
Try changing the ScrollView
to a LinearLayout
(You might need to remove the android:fillViewport="true"
line) and then create a separate ScrollView
inside the LinearLayout
. 尝试将
ScrollView
更改为LinearLayout
(您可能需要删除android:fillViewport="true"
行),然后在LinearLayout
创建一个单独的ScrollView
。
If you need something on the bottom of the page (assuming you're doing something similar to this ) Here's a little trick that I found works. 如果您需要页面底部的某些内容(假设您正在执行与此类似的操作),这是我发现可行的一个小技巧。
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="100"
android:duplicateParentState="false" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
android:clipToPadding="true" >
</ScrollView>
</FrameLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal" >
</LinearLayout>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.