结果
期望的
我想要实现文本在TextView中间的期望效果,但一直没有成功。请问应该怎么做?
(注意:当我将此属性放在TextView本身上时,它能够工作,但在style.xml中不起作用——我需要在style xml中管理重力问题,因为我的布局中有太多的行和列)
style.xml
<style name="Normal">
<item name="android:textSize">15sp</item>
<item name="android:gravity">center</item>
</style>
my_layout.xml
<TableRow
android:id="@+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dip" >
<TextView
android:id="@+id/textView1"
android:layout_weight="1"
android:text="Column 1"
android:textAppearance="@style/Normal" />
<TextView
android:id="@+id/textView2"
android:layout_weight="1"
android:text="Column 2"
android:textAppearance="@style/Normal" />
</TableRow>
[编辑]: textSize影响外观。