为什么我看不到最后一个LinearLayout?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:background="@drawable/bg" android:layout_height="wrap_content"
android:orientation="vertical" android:padding="2dp"
android:theme="@android:style/Theme.NoTitleBar">
<LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" .../>
<ScrollView android:layout_width="wrap_content" android:layout_height="wrap_content">
<TableLayout android:layout_width="fill_parent" android:layout_height="wrap_content">
// TableRows created dynamically
</TableLayout>
</ScrollView>
<LinearLayout android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_gravity="bottom">
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text="Button" android:id="@+id/button1"></Button>
</LinearLayout>
</LinearLayout>`
编辑: android:layout_gravity="bottom"
最佳答案
会发生这种情况,因为您已将子级放在第一个衬垫布局中,并且 ScrollView 可能包含与屏幕相比更多的空间,因此该衬垫布局的最后一个子级没有更多的空间用于其 View 。
对于解决方案,您可以采用相对布局,或者根据您的要求为所有 subview 放置layout_weight。我认为最后一个选择对你来说更好。
关于java - LinearLayout不出现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6435030/