如果想要在LinearLayout中設(shè)置居中,需要用到gravity
android:gravity: ? takes care of its children
android:layout_gravity: ?takes care of itself.
<LinearLayout xmlns:tools="http://schemas.android.com/tools"
? ? android:id="@+id/activity_main"
? ? android:layout_width="match_parent"
? ? android:layout_height="match_parent"
? ? android:paddingBottom="@dimen/activity_vertical_margin"
? ? android:paddingLeft="@dimen/activity_horizontal_margin"
? ? android:paddingRight="@dimen/activity_horizontal_margin"
? ? android:paddingTop="@dimen/activity_vertical_margin"
? ? android:gravity="center_horizontal"
? ? tools:context="com.example.android.jlapp.MainActivity"/>