linearlayout 居中问题

来源:互联网 发布:sql语句高级查询 编辑:程序博客网 时间:2024/06/04 22:16

linearlayout  下的子控件使用android:layout_gravity=”center”  控件居左,没有达到居中的效果,这是需要在父控件中设置android:gravity="center"即可。

    <LinearLayout
        android:layout_height="49dp"
        android:layout_width="fill_parent"
        android:orientation="horizontal"
        android:layout_below="@id/base_hordivider"
        android:gravity="center"
        android:layout_alignParentBottom="true">

        <Button
            android:id="@+id/cancel"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:background="@drawable/button_hover"
            android:text="@string/ok"
            android:textColor="#ffffff"
            android:textSize="16dp" />
      
    </LinearLayout>

1 0
原创粉丝点击