至於什麼@Eugene^h建議,你可以刪除AlertDialog的稱號,並使用自定義XML佈局與一個TextView,將作爲您的標題。
爲此,您需要從對話框中刪除Window.FEATURE_NO_TITLE。
final View dialogView = View.inflate(this, R.layout.custom_dialog, null);
final AlertDialog alertDialog = new AlertDialog.Builder(this).create();
alertDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
TextView tvTitle = (TextView)dialogView.findViewById(R.id.tvTitle);
tvTitle.setText("Please help us to track the route, has this route arrived the stop?");
custom_dialog.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:padding="8dp"
android:layout_height="match_parent">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="@android:drawable/divider_horizontal_textfield">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This is the title"
android:id="@+id/tvTitle"/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This is the Message"
android:id="@+id/tvMessage"/>
<Button
android:id="@+id/date_time_set"
android:layout_weight="1"
android:layout_width="match_parent"
android:text="OK"
android:layout_height="0dp" />
</LinearLayout>
你最好的最好的是劃傷標題和和一個TextView作爲其替代品。 –