为什么我的按钮隐藏?
问题描述:
该按钮被隐藏...为什么?为什么我的按钮隐藏?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="15dp"
android:orientation="vertical">
<ListView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/feed_list"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="More"
android:id="@+id/feed_more"/>
</LinearLayout>
答
假设ListView
有足够的内容来填满整个屏幕,它会因为你告诉它wrap_content
。您可以使用加权指示ListView
占用尽可能多的屏幕作为可用时,按钮有什么后,它需要:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="15dp"
android:orientation="vertical">
<ListView
android:layout_width="fill_parent"
android:layout_height="0"
android:weight="1"
android:id="@+id/feed_list"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:weight="0"
android:text="More"
android:id="@+id/feed_more"/>
答
你需要给重1到列表视图。那么你的按钮将是可见的。尝试一下。