Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/186.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ANDROID:加权线性列表按钮消失_Android_Xml_Button_Android Linearlayout_Weighted - Fatal编程技术网

ANDROID:加权线性列表按钮消失

ANDROID:加权线性列表按钮消失,android,xml,button,android-linearlayout,weighted,Android,Xml,Button,Android Linearlayout,Weighted,我看过很多关于这方面的帖子,也尝试过很多解决方案,但由于某些原因,一切都不起作用。我只想让按钮共享相等的空间。。。请看一下我的xml代码,看看是否出了什么问题?谢谢 编辑:这似乎与设置背景有关。我删除了背景,所有内容共享相同的空间,但您仍然必须滚动。您的线性布局具有垂直方向,因此您应该使用android:layout\u width=“0dp”而不是android:layout\u height=“0dp”尝试删除android:weightSum=“120”,并将所有按钮上的and

我看过很多关于这方面的帖子,也尝试过很多解决方案,但由于某些原因,一切都不起作用。我只想让按钮共享相等的空间。。。请看一下我的xml代码,看看是否出了什么问题?谢谢



编辑:这似乎与设置背景有关。我删除了背景,所有内容共享相同的空间,但您仍然必须滚动。

您的线性布局具有垂直方向,因此您应该使用
android:layout\u width=“0dp”
而不是
android:layout\u height=“0dp”

尝试删除
android:weightSum=“120”
,并将所有按钮上的
android:layout\u weight=“20”
设置为
android:layout\u weight=“1”

这些按钮现在都出现了,但有没有办法让它们立即占据空白,它们只是一个接一个地列出。尝试使用android:layout\u width=为每个按钮“填充父项”(我不确定它是否是您想要的)。
我只希望按钮共享相等的空间…
这是什么意思?水平?垂直?请澄清您想要什么。

    <ScrollView android:id="@+id/scrollview1"
        android:layout_width="fill_parent" android:layout_height="fill_parent">
        <LinearLayout android:orientation="vertical"
            android:layout_width="fill_parent" android:layout_height="wrap_content"
            android:weightSum="120">
            <Button android:id="@+id/btn_mission" android:layout_width="0dp"
                android:layout_height="wrap_content" android:background="#8D8BB7"
                android:layout_weight="20" android:text="Mission">
            </Button>
            <Button android:id="@+id/btn_news" android:layout_width="0dp"
                android:layout_height="wrap_content" android:background="#8D8BB7"
                android:layout_weight="20" android:text="News/Events">
            </Button>
            <Button android:id="@+id/btn_studentservices"
                android:layout_width="0dp" android:layout_height="wrap_content"
                android:background="#8D8BB7" android:layout_weight="20"
                android:text="Student Services">
            </Button>
            <Button android:id="@+id/btn_facultyservices"
                android:layout_width="0dp" android:layout_height="wrap_content"
                android:background="#8D8BB7" android:layout_weight="20"
                android:text="Faculty Services">
            </Button>
            <Button android:id="@+id/btn_staff" android:layout_width="0dp"
                android:layout_height="wrap_content" android:background="#8D8BB7"
                android:layout_weight="20" android:text="Staff">
            </Button>
            <Button android:id="@+id/btn_library" android:layout_width="0dp"
                android:layout_height="wrap_content" android:background="#8D8BB7"
                android:layout_weight="20" android:text="Library">
            </Button>
        </LinearLayout>
    </ScrollView>
</LinearLayout>