AlertDialog风格使用的setView时() [英] AlertDialog style when using setView()
问题描述
默认AlertDialog看起来不错,并使用setMessage(),可以设置其文本 - 易
The Default AlertDialog looks nice, and using setMessage() one can set its text - easy.
但使用的setView()时,对话框将替换由给定的观点,这是很好的内容。
But when using setView(), the dialog replaces the content by the given view, which is fine.
不过,我想保持默认的补白/背景/风格。我寻找一个合适的风格,我看了一眼alert_dialog.xml,但没有发现任何有用的。
However, I'd like to keep the default paddings/background/style. I searched for a proper style and I had a look at alert_dialog.xml, but didn't find anything helpful.
如何申请默认的样式,没有模仿呢?
How can I apply the default style, without mimicking it?
推荐答案
要解决,你可以使用你的包裹布局中的FrameLayout的边缘,并在你的布局像这样加边距:
To fix the margins you can use wrap your Layout in a FrameLayout and add the margins in your Layout like this:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/dialog_margin_title"
android:layout_marginBottom="@dimen/dialog_margin"
android:layout_marginLeft="@dimen/dialog_margin"
android:layout_marginStart="@dimen/dialog_margin"
android:layout_marginRight="@dimen/dialog_margin"
android:layout_marginEnd="@dimen/dialog_margin"
android:orientation="vertical">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Please enter the email address of the person you would like to follow, this person will be notified." />
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textEmailAddress" />
</LinearLayout>
</FrameLayout>
这篇关于AlertDialog风格使用的setView时()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!