我需要使用自定义视图创建一个 AlertDialog
。
AlertDialog
的消息具有默认填充,但当我设置视图时,它没有填充。我想要获得与消息默认填充相同的填充。我正在使用扩展 Holo 主题的样式(如果相关的话)。
AlertDialog.Builder builder = new AlertDialog.Builder(PlaylistListView.this.getContext());
builder.setTitle("Title");
builder.setView(inflate(context, R.layout.music_player_create_dialog, null));
builder.setPositiveButton("OK", null);
builder.setNegativeButton("Cancel", null);
builder.show();
这是内容的布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/abc_dialog_padding_material"
android:paddingRight="@dimen/abc_dialog_padding_material"
android:paddingTop="@dimen/abc_dialog_padding_top_material"
android:paddingBottom="@dimen/abc_dialog_padding_top_material">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Title:"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="bottom"
android:background="@null"
android:layout_marginTop="20dp"/>
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@color/divider"/>
</LinearLayout>