ANDROID:加权线性列表按钮消失
我看过很多关于这方面的帖子,也尝试过很多解决方案,但由于某些原因,一切都不起作用。我只想让按钮共享相等的空间。。。请看一下我的xml代码,看看是否出了什么问题?谢谢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
编辑:这似乎与设置背景有关。我删除了背景,所有内容共享相同的空间,但您仍然必须滚动。您的线性布局具有垂直方向,因此您应该使用
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>