AlertDialog 的 XML?

我对标准 AlertDialog 的外观很满意。带有“是”按钮和“否”按钮。

但是我希望我的 AlertDialog 也有一个带有监听器的开关。据我了解,我需要创建自己的自定义 AlertDialog 来实现这一点。

我的问题是我可以找到标准 AlertDialog 及其按钮的 XML 文件吗?

编辑:我知道如何创建自定义警报对话框。我正在寻找标准警报对话框的 XML。这样我就可以以此为模板构建我的自定义警报对话框。

http://img1.mukewang.com/647c3f770001d05503250457.jpg

DIEA
浏览 128回答 1
1回答

当年话下

这是xml从 的标准文件中检索到的标准 AlertDialogjar的AndroidX AppCompat library:abc_alert_dialog_material.xml<?xml version="1.0" encoding="utf-8"?><!--&nbsp; &nbsp; &nbsp;Copyright (C) 2015 The Android Open Source Project&nbsp; &nbsp; &nbsp;Licensed under the Apache License, Version 2.0 (the "License");&nbsp; &nbsp; &nbsp;you may not use this file except in compliance with the License.&nbsp; &nbsp; &nbsp;You may obtain a copy of the License at&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; http://www.apache.org/licenses/LICENSE-2.0&nbsp; &nbsp; &nbsp;Unless required by applicable law or agreed to in writing, software&nbsp; &nbsp; &nbsp;distributed under the License is distributed on an "AS IS" BASIS,&nbsp; &nbsp; &nbsp;WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.&nbsp; &nbsp; &nbsp;See the License for the specific language governing permissions and&nbsp; &nbsp; &nbsp;limitations under the License.--><androidx.appcompat.widget.AlertDialogLayout&nbsp; &nbsp; xmlns:android="http://schemas.android.com/apk/res/android"&nbsp; &nbsp; android:id="@+id/parentPanel"&nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; android:layout_height="wrap_content"&nbsp; &nbsp; android:gravity="start|left|top"&nbsp; &nbsp; android:orientation="vertical">&nbsp; &nbsp; <include layout="@layout/abc_alert_dialog_title_material"/>&nbsp; &nbsp; <FrameLayout&nbsp; &nbsp; &nbsp; &nbsp; android:id="@+id/contentPanel"&nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="wrap_content"&nbsp; &nbsp; &nbsp; &nbsp; android:minHeight="48dp">&nbsp; &nbsp; &nbsp; &nbsp; <View android:id="@+id/scrollIndicatorUp"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="1dp"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_gravity="top"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:background="?attr/colorControlHighlight"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:visibility="gone"/>&nbsp; &nbsp; &nbsp; &nbsp; <androidx.core.widget.NestedScrollView&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:id="@+id/scrollView"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="wrap_content"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:clipToPadding="false">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <LinearLayout&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="wrap_content"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:orientation="vertical">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <android.widget.Space&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:id="@+id/textSpacerNoTitle"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="@dimen/abc_dialog_padding_top_material"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:visibility="gone"/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <TextView&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:id="@android:id/message"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; style="@style/TextAppearance.AppCompat.Subhead"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="wrap_content"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:paddingLeft="?attr/dialogPreferredPadding"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:paddingRight="?attr/dialogPreferredPadding"/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <android.widget.Space&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:id="@+id/textSpacerNoButtons"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="@dimen/abc_dialog_padding_top_material"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:visibility="gone"/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </LinearLayout>&nbsp; &nbsp; &nbsp; &nbsp; </androidx.core.widget.NestedScrollView>&nbsp; &nbsp; &nbsp; &nbsp; <View android:id="@+id/scrollIndicatorDown"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="1dp"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_gravity="bottom"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:background="?attr/colorControlHighlight"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:visibility="gone"/>&nbsp; &nbsp; </FrameLayout>&nbsp; &nbsp; <FrameLayout&nbsp; &nbsp; &nbsp; &nbsp; android:id="@+id/customPanel"&nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="wrap_content"&nbsp; &nbsp; &nbsp; &nbsp; android:minHeight="48dp">&nbsp; &nbsp; &nbsp; &nbsp; <FrameLayout&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:id="@+id/custom"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="wrap_content"/>&nbsp; &nbsp; </FrameLayout>&nbsp; &nbsp; <include layout="@layout/abc_alert_dialog_button_bar_material"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;android:layout_width="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;android:layout_height="wrap_content"/></androidx.appcompat.widget.AlertDialogLayout>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java