Как выровнять LinearLayout по центру его родительского объекта?

Я рассмотрел множество похожих вопросов здесь, в SO, но ничего не помогло. {{1} } У меня есть иерархия различных вложенных макетов, все имеют android: layout_width = "fill_parent" , а самый внутренний макет имеет android: layout_width = "wrap_content - мне нужно выровнять он в центре (по горизонтали). Как мне это сделать?

Обновление: : ​​Я нашел причину проблемы - если я помещу внутренний LinearLayout в RelativeLayout с помощью android: layout_width = " fill_parent ", он по-прежнему обертывает свое содержимое. Однако TableRow действительно заполняет экран.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
    <FrameLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >
        <TableLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >
            <TableRow >
            <LinearLayout 
            android:orientation="horizontal"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content">
                    <TextView
                    android:layout_height="wrap_content"
                    android:layout_width="wrap_content"
                    android:text="1"
                    android:textAppearance="?android:attr/textAppearanceLarge" />

                     <TextView
                    android:layout_height="wrap_content"
                    android:layout_width="wrap_content"
                    android:text="2"
                    android:textAppearance="?android:attr/textAppearanceLarge" />
             </LinearLayout>
           </TableRow>
        </TableLayout>
    </FrameLayout>
</LinearLayout>
74
задан Violet Giraffe 26 July 2013 в 12:50
поделиться