相关疑难解决方法(0)

布局权重在ScrollView中不起作用

我想将布局权重分配给一个LinearLayout内部的几个项目ScrollView.但是,ScrollView忽略了LinearLayout weightSum.

我的目标是将布局的权重分为2,1,1(总和为4),但这在a内部无法正常工作ScrollView.

我该如何解决这个布局问题?

main.xml中

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/scrollView1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <LinearLayout 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" 
        android:weightSum="4">

        <LinearLayout android:id="@+id/logo"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" 
            android:layout_weight="2"
            android:background="#FFFFFF" />

        <LinearLayout android:id="@+id/logo1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" 
            android:layout_weight="1"
            android:background="#000000" />


        <LinearLayout android:id="@+id/logobutton"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" 
            android:layout_weight="1" 
            android:background="#4B4B4B" />

    </LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)

android android-layout

49
推荐指数
1
解决办法
3万
查看次数

Android布局高度最小为match_parent,但如果内容大于parent,则为wrap_content

我在ScrollView中有一个LinearLayout(内容视图容器).我希望LinearLayout的最小高度为"match_parent",但如果内容高于父级,那么我希望LinearLayout能够"wrap_content".

我的LinearLayout有一个平铺的背景图像,使它看起来像背景是黄色的合法垫.但是,如果LinearLayout中的内容很短,那么我在屏幕底部有一个黑色空白部分,因为LinearLayout只是包装内容.

我希望黄色的法律垫背景覆盖整个屏幕,但我不能把它放在ScrollView上,因为那时背景不会随着内容滚动.我不希望内容浮在垫子上面,我希望它们固定在一起.

有没有办法实现这个目标?

编辑:

进一步的研究...... ScrollView和LinearLayout都是683px高,因此它们都是相同的尺寸,这很好.但问题是它们都应该是766px高(前一个片段的大小正被这个片段取代).

android android-layout

19
推荐指数
1
解决办法
3926
查看次数

标签 统计

android ×2

android-layout ×2