我是新手,在Android的努力使这个布局: 如何使这个布局Android的XML
只要我想达到的目标: ,因为它需要但不是红色的容器应采取尽可能多的空间很多绿色容器必须缩小。如果项目太多,红色容器将滚动。绿色容器也总是以橙色为中心,如果有空间的话(如果没有,它实际上仍然居中)。 。
我不知道该怎么都做:(这里是我的尝试:
的问题是,我要永远保持绿色容器的高度(不了minHeight不工作我无法理解。为什么),并以橙色一个绿色集装箱中心我有问题,方案2(你可以在图片中看到),该代码在第一种情形下好
<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">
<ScrollView
android:id="@+id/red_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/holo_red_dark"
android:scrollbarAlwaysDrawVerticalTrack="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- Items are here -->
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="@+id/orange_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/holo_orange_dark"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:id="@+id/green_container"
android:layout_width="100dp"
android:background="@android:color/holo_green_dark"
android:layout_height="50dp"
android:orientation="horizontal">
<!-- My content -->
</LinearLayout>
</LinearLayout>
</LinearLayout>
编辑:了minHeight没有帮助:
编辑:图像用户非法参数:
你需要支持2.3 Android版本? – eleven 2014-10-04 14:20:51
这可以很容易地实现使用相对布局 – 2014-10-04 14:22:11
你的红色视图中的“项目”是什么? – Squonk 2014-10-04 14:26:19