我在我的TableLayout
里面有两个button
,但文本不在中心,我尝试使用android:gravity="center"
和android android:layout_gravity="center"
,但似乎不起作用。文本的中心重力属性在android按钮中不起作用
我该如何解决这个问题?在此先感谢
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="20dp"
android:id="@+id/bawah"
android:layout_margin="10dp"
android:layout_alignParentBottom="true"
>
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="10">
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:text="Approve"
android:textColor="@color/putih"
android:textAlignment="center"
android:layout_gravity="center"
android:gravity="center"
android:layout_weight="4.9"
android:id="@+id/approve"
android:background="@drawable/backhijau"
/>
<TextView android:layout_height="wrap_content"
android:layout_width="0dip"
android:layout_weight="0.2"/>
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="4.9"
android:textAlignment="center"
android:text="Tolak"
android:layout_gravity="center"
android:gravity="center"
android:textColor="@color/putih"
android:id="@+id/tolak"
android:background="@drawable/backmerah"
/>
</TableRow>
</TableLayout>
</RelativeLayout>
不工作意味着什么?请更清楚。 –
我认为你定义了权重,这就是为什么它不起作用 –
海@jackjay,编辑我的问题 –