我有一個TextView
和3 Buttons
居中在RelativeLayout
,並且其中的所有三個文本左對齊父中心作爲最左邊的行。安卓文本將不會與中心對齊
我試圖改變的TextView
,Buttons
和佈局的gravity
,但沒有什麼工作,我很困惑,因爲我從來沒有見過的Android對齊文本是這樣的。
我希望Button
文字以每個Button
爲中心,頂端文字居中對齊。
的是什麼樣子的圖像是在這裏:http://i.stack.imgur.com/9lHEd.png
這裏是我的xml:
<RelativeLayout 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" >
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_margin="20dp"
android:gravity="center_horizontal"
android:text="@string/greeting"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Button
android:id="@+id/startQuizButton"
android:layout_width="280dp"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true"
android:onClick="@string/startQuiz"
android:text="@string/start_quiz" />
<Button
android:id="@+id/lessonsButton"
android:layout_width="280dp"
android:layout_height="wrap_content"
android:layout_below="@+id/startQuizButton"
android:layout_centerHorizontal="true"
android:onClick="@string/startLesson"
android:text="@string/lessonsString" />
<Button
android:id="@+id/viewAllButton"
android:layout_width="280dp"
android:layout_height="wrap_content"
android:layout_below="@+id/lessonsButton"
android:layout_centerHorizontal="true"
android:onClick="@string/showAll"
android:text="@string/view_all" />
我剛剛嘗試過您的代碼,並且仍然按照原始屏幕截圖對齊文本。我會嘗試刪除相關的佈局,看看它做了什麼。 – Jordan 2012-08-06 14:52:54
奇怪的是,我測試了一個實際的手機和我發佈的作品。我會發布我正在獲取的屏幕截圖。 – prolink007 2012-08-06 14:54:09
已發佈屏幕截圖。 – prolink007 2012-08-06 14:56:15