我对两个XML属性有点困惑:match_parent和fill_parent.似乎两者都是一样的.它们之间有什么区别吗?
在下面的代码中,它viewflipper并没有占据整个屏幕,它只是围绕着textview. 为什么会发生这种情况?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#0000ff" >
<ViewFlipper android:id="@+id/ViewFlipper01"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#aa0000"
android:layout_gravity="center">
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"></TextView>
</ViewFlipper>
</ScrollView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud) 可能重复:
android FILL_PARENT和MATCH_PARENT中match_parent和fill_parent属性的区别是什么
我已经通过android开发者网站,他们给出以下差异:
注意:从Android 2.2(API级别8)开始,"fill_parent"已重命名为"match_parent"以更好地反映行为.原因是如果将视图设置为"fill_parent",则在考虑兄弟视图后,它不会展开以填充剩余空间,而是扩展以匹配父视图的大小,无论它与任何兄弟视图重叠.
但任何人都可以用例子解释.所以事情可能会清楚.