【发布时间】:2014-05-28 08:14:19
【问题描述】:
我正在尝试制作具有可滚动 layout 的 android 应用程序,该应用程序可以垂直和水平滚动不同的其他 layouts,我希望这些不同布局的每个布局都适合屏幕宽度并几乎适合高度,看看下图说明了我正在尝试做的事情:
我只是尝试将这些布局的所有 width 和 height 设置为 match_parent 并将它们全部放在分配有的 main_layout 中match_parent 参数,然后我创建一个 Layout 并将 Layouts(4,1,5) 放入其中并将此 Layout 放入 ScrollView ,然后我将 main_layout HorizontalScrollView 中的布局,其中包含三个布局(Layout3、Layout(4,1,5)、Layout2),但这给了我对布局的干扰视图。
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.9" >
<!-- just to give it 0.9 of the screen in order to give a space to the top layout (it takes 0.1 and the weight sum is 1) -->
<LinearLayout
android:id="@+id/main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="horizontal" >
<LinearLayout
android:id="@+id/Layout3"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none" >
<LinearLayout
android:id="@+id/Layouts(4,1,5)"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/Layout4"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</LinearLayout>
<LinearLayout
android:id="@+id/Layout1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</LinearLayout>
<LinearLayout
android:id="@+id/Layout5"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</LinearLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="@+id/Layout2"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</LinearLayout>
</LinearLayout>
</HorizontalScrollView>
【问题讨论】:
标签: android android-layout layout