Android 垂直滚动两帧布局或片段
我试过这个-Android 垂直滚动两帧布局或片段,android,android-layout,Android,Android Layout,我试过这个- <?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" android:fillViewpor
<?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"
android:fillViewport="true"
android:isScrollContainer="true"
android:layout_below="@+id/rootLayout"
android:layout_centerHorizontal="true">
<RelativeLayout
android:id="@+id/rootLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
android:id="@+id/shop_detail_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" />
<FrameLayout
android:id="@+id/item_detail_container"
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
android:layout_height="wrap_content" />
</RelativeLayout>
</ScrollView>
我试图在一个屏幕上得到两个垂直滚动的片段。上面的代码只显示了片段1,也没有滚动。任何帮助都将不胜感激
提前谢谢你。像这样试试吧,它对我很管用
<LinearLayout...orientation = "horizontal>
<ScrollView>
<FrameLayout/>
</ScrollView>
<ScrollView>
<FrameLayout/>
</ScrollView>
</LinearLayout>
像这样试试它对我很管用
<LinearLayout...orientation = "horizontal>
<ScrollView>
<FrameLayout/>
</ScrollView>
<ScrollView>
<FrameLayout/>
</ScrollView>
</LinearLayout>
片段在您的案例中重叠。如果要使用相对布局,请按如下所示使用它
<RelativeLayout
android:id="@+id/rootLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
android:id="@+id/shop_detail_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" />
<FrameLayout
android:layout_below="@id/shop_detail_container"
android:id="@+id/item_detail_container"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:id="@+id/rootLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
android:id="@+id/shop_detail_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<FrameLayout
android:id="@+id/item_detail_container"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
或者使用线性布局,如下所示
<RelativeLayout
android:id="@+id/rootLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
android:id="@+id/shop_detail_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" />
<FrameLayout
android:layout_below="@id/shop_detail_container"
android:id="@+id/item_detail_container"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:id="@+id/rootLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
android:id="@+id/shop_detail_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<FrameLayout
android:id="@+id/item_detail_container"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
在您的案例中,片段重叠。如果要使用相对布局,请按如下所示使用它
<RelativeLayout
android:id="@+id/rootLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
android:id="@+id/shop_detail_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" />
<FrameLayout
android:layout_below="@id/shop_detail_container"
android:id="@+id/item_detail_container"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:id="@+id/rootLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
android:id="@+id/shop_detail_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<FrameLayout
android:id="@+id/item_detail_container"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
或者使用线性布局,如下所示
<RelativeLayout
android:id="@+id/rootLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
android:id="@+id/shop_detail_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" />
<FrameLayout
android:layout_below="@id/shop_detail_container"
android:id="@+id/item_detail_container"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:id="@+id/rootLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
android:id="@+id/shop_detail_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<FrameLayout
android:id="@+id/item_detail_container"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
尝试将RelativeLayout更改为LinearLayout尝试将RelativeLayout更改为LinearLayout Hey@Akash,谢谢你,伙计!它真的帮助我完成了我想做的事情。高度显示不正确,所以我使用了这个itemDetail.getLayoutParams().Height=windowHeight代码>shopDetail.getLayoutParams().height=windowHeight代码>嘿@Akash,谢谢你,伙计!它真的帮助我完成了我想做的事情。高度显示不正确,所以我使用了这个itemDetail.getLayoutParams().Height=windowHeight代码>shopDetail.getLayoutParams().height=windowHeight代码>