亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

AlertDialog 的 XML?

AlertDialog 的 XML?

DIEA 2023-06-04 15:38:14
我對標準 AlertDialog 的外觀很滿意。帶有“是”按鈕和“否”按鈕。但是我希望我的 AlertDialog 也有一個帶有監聽器的開關。據我了解,我需要創建自己的自定義 AlertDialog 來實現這一點。我的問題是我可以找到標準 AlertDialog 及其按鈕的 XML 文件嗎?編輯:我知道如何創建自定義警報對話框。我正在尋找標準警報對話框的 XML。這樣我就可以以此為模板構建我的自定義警報對話框。
查看完整描述

1 回答

?
當年話下

TA貢獻1890條經驗 獲得超9個贊

這是xml從 的標準文件中檢索到的標準 AlertDialogjar的AndroidX AppCompat library:


abc_alert_dialog_material.xml

<?xml version="1.0" encoding="utf-8"?>

<!--

     Copyright (C) 2015 The Android Open Source Project


     Licensed under the Apache License, Version 2.0 (the "License");

     you may not use this file except in compliance with the License.

     You may obtain a copy of the License at


          http://www.apache.org/licenses/LICENSE-2.0


     Unless required by applicable law or agreed to in writing, software

     distributed under the License is distributed on an "AS IS" BASIS,

     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

     See the License for the specific language governing permissions and

     limitations under the License.

-->


<androidx.appcompat.widget.AlertDialogLayout

    xmlns:android="http://schemas.android.com/apk/res/android"

    android:id="@+id/parentPanel"

    android:layout_width="match_parent"

    android:layout_height="wrap_content"

    android:gravity="start|left|top"

    android:orientation="vertical">


    <include layout="@layout/abc_alert_dialog_title_material"/>


    <FrameLayout

        android:id="@+id/contentPanel"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:minHeight="48dp">


        <View android:id="@+id/scrollIndicatorUp"

              android:layout_width="match_parent"

              android:layout_height="1dp"

              android:layout_gravity="top"

              android:background="?attr/colorControlHighlight"

              android:visibility="gone"/>


        <androidx.core.widget.NestedScrollView

            android:id="@+id/scrollView"

            android:layout_width="match_parent"

            android:layout_height="wrap_content"

            android:clipToPadding="false">


            <LinearLayout

                android:layout_width="match_parent"

                android:layout_height="wrap_content"

                android:orientation="vertical">


                <android.widget.Space

                    android:id="@+id/textSpacerNoTitle"

                    android:layout_width="match_parent"

                    android:layout_height="@dimen/abc_dialog_padding_top_material"

                    android:visibility="gone"/>


                <TextView

                    android:id="@android:id/message"

                    style="@style/TextAppearance.AppCompat.Subhead"

                    android:layout_width="match_parent"

                    android:layout_height="wrap_content"

                    android:paddingLeft="?attr/dialogPreferredPadding"

                    android:paddingRight="?attr/dialogPreferredPadding"/>


                <android.widget.Space

                    android:id="@+id/textSpacerNoButtons"

                    android:layout_width="match_parent"

                    android:layout_height="@dimen/abc_dialog_padding_top_material"

                    android:visibility="gone"/>

            </LinearLayout>

        </androidx.core.widget.NestedScrollView>


        <View android:id="@+id/scrollIndicatorDown"

              android:layout_width="match_parent"

              android:layout_height="1dp"

              android:layout_gravity="bottom"

              android:background="?attr/colorControlHighlight"

              android:visibility="gone"/>


    </FrameLayout>


    <FrameLayout

        android:id="@+id/customPanel"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:minHeight="48dp">


        <FrameLayout

            android:id="@+id/custom"

            android:layout_width="match_parent"

            android:layout_height="wrap_content"/>

    </FrameLayout>


    <include layout="@layout/abc_alert_dialog_button_bar_material"

             android:layout_width="match_parent"

             android:layout_height="wrap_content"/>


</androidx.appcompat.widget.AlertDialogLayout>



查看完整回答
反對 回復 2023-06-04
  • 1 回答
  • 0 關注
  • 165 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號