我正在尝试构建类似标题的东西.我尝试在TextView上使用android:gravity="center"
和android:textAlignment="center"
但它不会使文本居中.我不知道问题出在哪里.
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<TableRow
android:id="@+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#008000" >
<TextView
android:id="@+id/HeaderTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
<!--android:textAlignment="center"
android:gravity="center"-->
android:text="@string/header"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#FFF"
android:textStyle="italic" />
</TableRow>
</TableLayout>
Run Code Online (Sandbox Code Playgroud)
shi*_*edi 14
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<TableRow
android:id="@+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:background="#008000" >
<TextView
android:id="@+id/HeaderTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="header"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#FFF"
android:textStyle="italic" />
</TableRow>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
20977 次 |
最近记录: |