wrap_content指大小由包裹的内容大小自动伸缩
match_parent指大小填充父容器
如图所示如果使用wrap_content,则居中center无效,因为他它先将没有占满的区域占满
附上源码:
<?xml version="1.0" encoding="utf-8"?>
<Button
android:layout_width=“match_parent”
android:layout_height=“wrap_content”
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="下面的按钮英文保持原状"
android:textColor="@color/black"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="下面的按钮英文保持原状"
android:textColor="@color/black"
/>