[英]scrollview inside another scrollview is not working
I have added vertical scrollview to another existing vertical scrollview in Layout(xml) file. 我已经在Layout(xml)文件中将垂直滚动视图添加到另一个现有的垂直滚动视图中。 But it is not working.
但这是行不通的。 Only outer scrollview is working .
仅外部scrollview有效。
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="fill_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/outer_linear_layout"
android:orientation="vertical"
android:isScrollContainer="true">
<RelativeLayout
android:id="@+id/blue_bg_layout_sa"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/bluebg_320_568">
<ImageView
android:id="@+id/logo_img_view_sa"
android:layout_height="150dp"
android:layout_width="250dp"
android:layout_marginTop="20dp"
android:background="@drawable/logo_home_250_150"
android:layout_centerHorizontal="true" />
<ScrollView
android:id="@+id/claim_tiles_scroll_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@id/logo_img_view_sa">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="300dp">
<ImageView
android:id="@+id/windshield_btn"
android:layout_height="87dp"
android:layout_width="105dp"
android:layout_marginTop="5dp"
android:background="@drawable/windshield_105_87"
android:onClick="showClaimForm"/>
<TextView
android:id="@+id/windshield_btn_lbl"
android:layout_width="105dp"
android:layout_height="20dp"
android:text="@string/windshield"
android:textColor="@android:color/white"
android:layout_below="@id/windshield_btn"
android:layout_alignStart="@id/windshield_btn"
android:textSize="@dimen/system12"
android:gravity="center"/>
<ImageView
android:id="@+id/pdr_btn"
android:layout_height="87dp"
android:layout_width="105dp"
android:layout_marginTop="5dp"
android:background="@drawable/pdr_105_87"
android:onClick="showClaimForm"/>
<TextView
android:id="@+id/pdr_btn_lbl"
android:layout_width="105dp"
android:layout_height="20dp"
android:text="@string/pdr"
android:textColor="@android:color/white"
android:layout_below="@id/pdr_btn"
android:layout_alignStart="@id/pdr_btn"
android:textSize="@dimen/system12"
android:gravity="center"/>
<ImageView
android:id="@+id/tire_btn"
android:layout_height="87dp"
android:layout_width="105dp"
android:layout_marginTop="5dp"
android:background="@drawable/tire_105_87"
android:onClick="showClaimForm"/>
<TextView
android:id="@+id/tire_btn_lbl"
android:layout_width="105dp"
android:layout_height="20dp"
android:text="@string/pdr"
android:textColor="@android:color/white"
android:layout_below="@id/tire_btn"
android:layout_alignStart="@id/tire_btn"
android:textSize="@dimen/system12"
android:gravity="center"/>
<ImageView
android:id="@+id/wheel_btn"
android:layout_height="87dp"
android:layout_width="105dp"
android:layout_marginTop="5dp"
android:background="@drawable/wheel_105_87"
android:onClick="showClaimForm"/>
<TextView
android:id="@+id/wheel_btn_lbl"
android:layout_width="105dp"
android:layout_height="20dp"
android:text="@string/wheel"
android:textColor="@android:color/white"
android:layout_below="@id/wheel_btn"
android:layout_alignStart="@id/wheel_btn"
android:textSize="@dimen/system12"
android:gravity="center"/>
<ImageView
android:id="@+id/key_btn"
android:layout_height="87dp"
android:layout_width="105dp"
android:layout_marginTop="5dp"
android:background="@drawable/key_replacement_105_87"
android:onClick="showClaimForm"/>
<TextView
android:id="@+id/key_btn_lbl"
android:layout_width="105dp"
android:layout_height="20dp"
android:text="@string/key"
android:textColor="@android:color/white"
android:layout_below="@id/key_btn"
android:layout_alignStart="@id/key_btn"
android:textSize="@dimen/system12"
android:gravity="center"/>
<ImageView
android:id="@+id/gap_btn"
android:layout_height="87dp"
android:layout_width="105dp"
android:layout_marginTop="5dp"
android:background="@drawable/gap_105_87"
android:onClick="showClaimForm"/>
<TextView
android:id="@+id/gap_btn_lbl"
android:layout_width="105dp"
android:layout_height="20dp"
android:text="@string/gap"
android:textColor="@android:color/white"
android:layout_below="@id/gap_btn"
android:layout_alignStart="@id/gap_btn"
android:textSize="@dimen/system12"
android:gravity="center"/>
<ImageView
android:id="@+id/interior_btn"
android:layout_height="87dp"
android:layout_width="105dp"
android:layout_marginTop="5dp"
android:background="@drawable/interior_protection_105_87"
android:onClick="showClaimForm"/>
<TextView
android:id="@+id/interior_btn_lbl"
android:layout_width="105dp"
android:layout_height="20dp"
android:text="@string/interior"
android:textColor="@android:color/white"
android:layout_below="@id/interior_btn"
android:layout_alignStart="@id/interior_btn"
android:textSize="@dimen/system12"
android:gravity="center"/>
<ImageView
android:id="@+id/exterior_btn"
android:layout_height="87dp"
android:layout_width="105dp"
android:layout_marginTop="5dp"
android:background="@drawable/exterior_protection_105_87"
android:onClick="showClaimForm"/>
<TextView
android:id="@+id/exterior_btn_lbl"
android:layout_width="105dp"
android:layout_height="20dp"
android:text="@string/exterior"
android:textColor="@android:color/white"
android:layout_below="@id/exterior_btn"
android:layout_alignStart="@id/exterior_btn"
android:textSize="@dimen/system12"
android:gravity="center"/>
<ImageView
android:id="@+id/theft_btn"
android:layout_height="87dp"
android:layout_width="105dp"
android:layout_marginTop="5dp"
android:background="@drawable/theft_105_87"
android:onClick="showClaimForm"/>
<TextView
android:id="@+id/theft_btn_lbl"
android:layout_width="105dp"
android:layout_height="20dp"
android:text="@string/theft"
android:textColor="@android:color/white"
android:layout_below="@id/theft_btn"
android:layout_alignStart="@id/theft_btn"
android:textSize="@dimen/system12"
android:gravity="center"/>
</LinearLayout>
</ScrollView>
</RelativeLayout>
</LinearLayout>
Please provide help with proper answer. 请提供正确答案的帮助。 Thanks in advance
提前致谢
You can't do it! 你做不到!
As the documentation says: 如文档所述 :
A ScrollView is a FrameLayout, meaning you should place one child in it containing the entire contents to scroll
ScrollView是一个FrameLayout,这意味着您应在其中放置一个包含所有要滚动内容的子级
If you try it, you should get this exception: 如果尝试,应该得到以下异常:
IllegalStateException "Scrollview can host only one direct child"
One solution can be to add a LinearLayout
as a direct child and then put the other ScrollView
inside it. 一种解决方案是将
LinearLayout
作为直接子级添加,然后将另一个ScrollView
放入其中。
Add "android:fillViewport" to attribute to your parent ScrollView and set it to true. 将“ android:fillViewport”添加到父ScrollView的属性,并将其设置为true。 So they look like this.
所以他们看起来像这样。
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:fillViewport="true">
You cannot provide scrolling within scrollable view. 您无法在可滚动视图中提供滚动。 This applies to all views.
这适用于所有视图。 Eg 1.ScrollView As Parent and LisView as child or vice versa.
例如:1.ScrollView作为父级,LisView作为子级,反之亦然。 2.ScrollView as Parent and GridView as child or vice versa.
2. ScrollView作为父级,而GridView作为子级,反之亦然。 3.ScrollView within ScrollView.
3. ScrollView中的ScrollView。
The Only Solution to This Scrolling Problem is:-- 解决此滚动问题的唯一方法是:-
-->You need to Calculate the Inner ScrollView's Length and make it that large. ->您需要计算内部ScrollView的长度并将其变大。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.