【发布时间】:2020-05-22 14:31:16
【问题描述】:
我想创建一个如下图所示的布局,
这是我的代码,
<?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">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="30dp"
android:id="@+id/dynamic_linear_layout"
android:weightSum="2"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="1"
android:layout_margin="0dp"
>
<FrameLayout
android:background="@color/lb_grey"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/container1"
android:layout_weight="1">
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/container2"
android:layout_weight="1">
</FrameLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_margin="0dp"
android:layout_weight="1"
>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/container3"
android:layout_weight="1">
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/container4"
android:layout_weight="1">
</FrameLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="horizontal"
android:layout_margin="10dp"
android:layout_weight="1"
>
<FrameLayout
android:background="#FF1122"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/container5"
android:layout_weight="1">
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/container6"
android:layout_weight="1">
</FrameLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
如您所见,XML 布局中有 6 个用户容器,我希望像图像一样在屏幕上只看到 4 个用户。当我滚动菜单时,我应该能够看到其他 2 个用户,但在我的代码中我无法滚动并且永远看不到其他 2 个用户。 你有什么想法吗?
【问题讨论】:
标签: xml android-studio layout