Моя таблица заполнена динамическими данными, поэтому я добавляю TableRows и ее представления в код. TableLayout и первая строка (мой заголовок) встроены в xml. Гравитация, установленная в центре, работает над этими элементами. Но установка Gravity в центр моего динамически созданного TableRows и Views не работает.TextView Gravity не работает в TableLayout
<TableLayout
android:id="@+id/poweredEquip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:gravity="center"
android:padding="10dip">
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/tab_bg_unselected"
android:gravity="center">
<TextView
android:text="Serial"
android:textSize="15sp"
android:textColor="@android:color/black"
android:layout_width="130px"
android:layout_height="wrap_content"
android:ellipsize="middle"
android:gravity="center"
android:layout_column="1"/>
<TextView
android:text="Model"
android:textSize="15sp"
android:textColor="@android:color/black"
android:layout_width="110px"
android:layout_height="wrap_content"
android:ellipsize="middle"
android:gravity="center"
android:layout_column="2"/>
<TextView
android:text="Status"
android:textSize="15sp"
android:textColor="@android:color/black"
android:layout_width="150px"
android:layout_height="wrap_content"
android:ellipsize="middle"
android:gravity="center"
android:layout_column="3"/>
<TextView
android:text="Tool Turned"
android:textSize="15sp"
android:textColor="@android:color/black"
android:layout_width="100px"
android:layout_height="wrap_content"
android:ellipsize="middle"
android:gravity="center"
android:layout_column="4"/>
<TextView
android:text="Hours"
android:textSize="15sp"
android:textColor="@android:color/black"
android:layout_width="110px"
android:layout_height="wrap_content"
android:ellipsize="middle"
android:gravity="center"
android:layout_column="5"/>
<TextView
android:text="Trailer Model"
android:textSize="15sp"
android:textColor="@android:color/black"
android:layout_width="110px"
android:layout_height="wrap_content"
android:ellipsize="middle"
android:gravity="center"
android:layout_column="6"/>
</TableRow>
<TableLayout>
Activity.cs
TableLayout powered = (TableLayout) FindViewById(Resource.Id.poweredEquip);
TableRow.LayoutParams p = new TableRow.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.WrapContent) {Gravity = GravityFlags.Center};
TableRow.LayoutParams p1 = new TableRow.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.WrapContent) {Column = 1, Gravity = GravityFlags.Center};
TableRow row = new TableRow(this) { LayoutParameters = p };
text = new TextView(this) {Text = dr["Serial"].ToString(), LayoutParameters = p1};
text.SetPadding(8, 8, 8, 8);
text.SetMaxWidth(150);
text.SetMinWidth(150);
row.AddView(text);
powered.AddView(row);
это текст появляется? – JRaymond
Да. Все работает, кроме выравнивания. – jmease