I have a linearlayout and in it another linearlayout.
How can I centre the son in its parent?
these didn't help:
android:layout_gravity="center_horizontal"
android:layout_gravity="center"
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/app_widget_nodata_root"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="30dp"
android:paddingBottom="30dp"
android:background="@drawable/widget_bg_info1">
<!--
========================================================================
* Information layout - contains the explanation text on the background
========================================================================
-->
<TextView
android:id="@+id/text_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="20dp"
android:text="@string/widget_nodata_title"
android:textColor="@color/solid_white"
android:paddingLeft="10dp"
android:textSize="22sp" />
<LinearLayout
android:id="@+id/layout_buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:paddingTop="20dp"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="130dp"
android:layout_height="wrap_content"
android:background="@drawable/button_blue"
android:clickable="true"
android:gravity="center"
android:orientation="horizontal"
android:paddingLeft="5dp"
android:paddingRight="5dp" >
<TextView
android:id="@+id/text_btn_enter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/widget_no_data_accept"
android:textColor="#000000" />
</LinearLayout>
<LinearLayout
android:layout_width="130dp"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:background="@drawable/button_blue"
android:clickable="true"
android:gravity="center"
android:orientation="horizontal"
android:paddingLeft="5dp"
android:paddingRight="5dp" >
<TextView
android:id="@+id/text_btn_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/widget_no_data_close"
android:textColor="#000000" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
I have tried the following, unsuccessfully:
<LinearLayout
android:id="@+id/layout_buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center"
android:paddingTop="20dp"
android:orientation="horizontal" >
I prefer not to complicate things and to not add another layer of inner RelativeLayout
Here is my result: