以编程方式解决一些事情,我想你可以使用自定义布局对话框。
如果您想在对话框中使用自定义布局,请创建布局并通过调用AlertDialog.Builder对象上的setView()将其添加到AlertDialog中。
默认情况下,自定义布局填充对话框窗口,但仍可以使用AlertDialog.Builder方法添加按钮和标题。
例如,以下是对话框的布局文件。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:src="@drawable/header_logo"
android:layout_width="match_parent"
android:layout_height="64dp"
android:scaleType="center"
android:background="#FFFFBB33"
android:contentDescription="@string/app_name" />
</LinearLayout>
要在DialogFragment膨胀的布局,获得与getLayoutInflater()一LayoutInflater和调用inflate(),其中第一个参数是布局资源ID,第二个参数是布局的父视图。然后您可以调用setView()将布局放置在对话框中。
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
// Get the layout inflater
LayoutInflater inflater = getActivity().getLayoutInflater();
// Inflate and set the layout for the dialog`enter code here`
// Pass null as the parent view because its going in the dialog layout
builder.setView(inflater.inflate(R.layout.dialog_signin, null))
有关此参考 '对话框' 描述中进一步引导在developer.android.com 链路如下 http://developer.android.com/guide/topics/ui/dialogs.html#CustomLayout
来源
2015-09-10 18:06:31
Mad
http://developer.android.com/intl/es/guide/提供topics/ui/dialogs.html –
我建议坚持Google的更新材料设计指南,而不是试图做到这一点。这种DialogBox风格不再是'in'了:P src:https://www.google.com/design/spec/components/dialogs.html –
感谢您的链接,我会考虑这两个。 – user1591668