I have a FrameLayout which has a ScrollView as the only child. During runtime I inflate a RelativeLayout which has a ScrollView within and add it to the FrameLayout开发者_如何学Go (This child view now overlaps the previous ScrollView). I have used a LockableScrollView as the first child of the FrameLayout so, I can disable it's scrolling by setting the scrollable property to false, the focusable and clickable properties are also set to false after the new child is added to the FrameLayout. But still I'm unable to scroll the new ScrollView. Any pointers?
The following is the Root layout.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/frame"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:id="@+id/relative_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/questions_bg">
<ImageView
android:id="@+id/questions_header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:scaleType="fitXY"
android:src="@drawable/header_bg" />
<com.package.ui.LockableScrollView
android:id="@+id/question_scrollview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@id/questions_header"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:scrollbarStyle="insideOverlay"
android:scrollbarFadeDuration="0"
android:fillViewport="true">
<!-- Some more views -->
</com.package.ui.LockableScrollView>
</RelativeLayout>
</FrameLayout>
The following is the child layout that is inflated during runtime and added to the FrameLayout.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
android:layout_marginBottom="20dp">
<ImageView
android:id="@+id/q_map_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:src="@drawable/en_question_map_header" />
<ImageView
android:id="@+id/q_map_bg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="@id/q_map_header"
android:src="@drawable/question_map_content" />
<ImageView
android:id="@+id/q_map_footer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="@id/q_map_bg"
android:paddingBottom="50dp"
android:src="@drawable/en_question_map_footer" />
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@id/q_map_header"
android:layout_above="@id/q_map_footer"
android:layout_marginLeft="28dp"
android:layout_marginRight="30dp"
android:layout_marginTop="14dp"
android:layout_marginBottom="14dp"
android:layout_alignLeft="@id/q_map_header"
android:layout_alignRight="@id/q_map_header"
android:fillViewport="true" >
<GridView
android:id="@+id/q_map_grid"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:numColumns="5"
android:verticalSpacing="8dp"
android:horizontalSpacing="8dp"
android:stretchMode="columnWidth"
android:gravity="center_horizontal" />
</ScrollView>
</RelativeLayout>
You can't place a scrollable container (Here GridView) within another scrollable container (Here ScrollView).
精彩评论