在对话框中设置textview的对齐方式

时间:2014-03-25 02:54:50

标签: android

尝试将所有内容置于对话框中。搜索栏是居中的,我正在使用的图像按钮,但我似乎无法将textViews置于中心,无论我做什么。

这是对话框的代码:

<TextView
    android:id="@+id/textView1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/pick_color"
    android:textAlignment="center" 
    />

<LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">

    <ImageButton
        android:layout_width="@dimen/large_brush"
        android:layout_height="@dimen/large_brush"
        android:layout_margin="2dp"
        android:background="#FF0000"
        android:layout_weight="1"
        android:tag="FF0000" />
    <ImageButton
        android:layout_width="@dimen/large_brush"
        android:layout_height="@dimen/large_brush"
        android:layout_margin="2dp"
        android:background="#CC66FF"
        android:layout_weight="1"
        android:tag="CC66FF" />
    <ImageButton
        android:layout_width="@dimen/large_brush"
        android:layout_height="@dimen/large_brush"
        android:layout_margin="2dp"
        android:background="#FFFF66"
        android:layout_weight="1"
        android:tag="FFFF66" />
    <ImageButton
        android:layout_width="@dimen/large_brush"
        android:layout_height="@dimen/large_brush"
        android:layout_margin="2dp"
        android:background="#66CCFF"
        android:layout_weight="1"
        android:tag="66CCFF" />
    <ImageButton
        android:layout_width="@dimen/large_brush"
        android:layout_height="@dimen/large_brush"
        android:layout_margin="2dp"
        android:background="#99FF33"
        android:layout_weight="1"
        android:tag="99FF33" />
    <ImageButton
        android:layout_width="@dimen/large_brush"
        android:layout_height="@dimen/large_brush"
        android:layout_margin="2dp"
        android:background="#000000"
        android:layout_weight="1"
        android:tag="#000000" />
</LinearLayout>

<TextView
    android:id="@+id/textView1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="@string/brsh_size"
    android:textAlignment="center" />

<SeekBar
    android:id="@+id/seekBar1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

<TextView
    android:id="@+id/textView2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="@string/ersr_size"
    android:textAlignment="center" />

<SeekBar
    android:id="@+id/seekBar2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

<TextView
    android:id="@+id/textView3"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="@string/use_pic"
    android:textAlignment="center"
    android:textAppearance="?android:attr/textAppearanceLarge" />

1 个答案:

答案 0 :(得分:1)

在文本视图中使用android:gravity =“center”

相关问题