[英]Multiple LinearLayout in ScrollView
我陷入尝试在ScrollView中插入多个LinearLayout或FrameLayout(无论如何)的问题。
我的结构是:
activity_layout.xml:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/container_main"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/border"
android:orientation="horizontal"/>
<LinearLayout
android:id="@+id/container_gallery"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/border"
android:orientation="horizontal"/>
<LinearLayout
android:id="@+id/container_video"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/border"
android:orientation="horizontal"/>
</LinearLayout>
例如,我的片段之一具有以下布局:
<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context="com.arbiec.conex.activities.MainActivity" />
问题!! 我只能看到前两个片段。
但是,当我在我的主布局(“活动”中的一个)中对LinearLayout的layout_height进行硬编码时,它就可以正常工作! 但是我不想对其进行硬编码,因为我不知道它会占用多少空间,它应该与wrap_content动态结合。
有任何想法吗?? 为什么会这样呢?
谢谢!
尝试修改后的布局:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:id="@+id/container_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/border"
/>
<FrameLayout
android:id="@+id/container_gallery"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/border"
/>
<FrameLayout
android:id="@+id/container_video"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/border"
/>
</LinearLayout>
</ScrollView>
希望有帮助!
试试这个代码...
在Scrollview中设置以下属性
android:fillViewport="true"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.