我已经尝试了几种方法来使其工作,但迄今为止没有成功。 需要使用主滚动视图来启用片段之间的滚动。 RelativeLayout就在那里,所以我们对齐所有片段父屏幕底部的“Back/Save/Done”按钮。如何在可滚动的RelativeLayout内启用LinearLayout内的滚动
现在在我的代码中,我通过编程方式将TableLayouts添加到了LinearLayout(我也尝试过使用GridViews而不是TableLayouts)。
<LinearLayout
android:id="@+id/layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/PageRadioGroup"
android:layout_alignParentTop="true"
android:layout_marginTop="3dp"
android:orientation="vertical" >
</LinearLayout>
此LinearLayout不可滚动,问题是我有4个表,只有第一个表是可见的。如果我在ScrollView/NestedScrollView中包含LinearLayout,则主父ScrollView将被禁用。
如何维护主滚动视图内的滚动,保持RelativeLayout结构并同时允许子LinearLayout内的滚动以查看其中的所有表。
这是我的布局XML
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp" >
<RadioGroup
android:id="@+id/PageRadioGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="19dp"
android:clickable="false"
android:orientation="horizontal" >
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:clickable="false" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false" />
</RadioGroup>
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="349dp"
android:layout_above="@+id/PageRadioGroup"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:focusableInTouchMode="true" >
</android.support.v4.view.ViewPager>
<Button
android:id="@+id/btnBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:text="@string/back"
android:textAllCaps="false" />
<Button
android:id="@+id/btnSave"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:text="@string/save"
android:textAllCaps="false"/>
<Button
android:id="@+id/btnDone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignStart="@+id/btnSave"
android:text="@string/done"
android:textAllCaps="false" />
<LinearLayout
android:id="@+id/layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/PageRadioGroup"
android:layout_alignParentTop="true"
android:layout_marginTop="3dp"
android:orientation="vertical" >
</LinearLayout>
</RelativeLayout>
</ScrollView>
谢谢!
它不是一个好方法,把一个垂直滚动容器垂直滚动容器内:)但你可以尝试添加机器人:nestedScrollingEnabled =“true”以你的LinearLayout – Prexx
机器人:nestedScrollingEnabled =“真”不工作。有没有办法让LinearLayout可以滚动而不使用内部ScrollView? – Hanaa
问题是:LinearLayout应该是可滚动的吗?还是有布局问题? – Prexx