有关style的查找



在源码中有如下AlertDialog

protected AlertDialog(Context context) {
        this(context, com.android.internal.R.style.Theme_Dialog_Alert);
    }

其中Theme_Dialog_Alert在哪里呢?

我们到res下面找到value里面的themes.xml里面的Theme_Dialog_Alert,但是这样是找不到的,需要把下划线"_"改成".",这样就ok了

    <!-- Default theme for alert dialog windows, which is used by the
         {@link android.app.AlertDialog} class.  This is basically a dialog
         but sets the background to empty so it can do two-tone backgrounds. -->
    <style name="Theme.Dialog.Alert">
        <item name="windowBackground">@android:color/transparent</item>
		 <item name="android:windowBackground">@android:color/transparent</item>
        <item name="windowTitleStyle">@android:style/DialogWindowTitle</item>
        <item name="windowIsFloating">true</item>
        <item name="windowContentOverlay">@null</item>
		 <item name="android:gravity">center</item>
    </style>


在AlertController中

        TypedArray a = mContext.obtainStyledAttributes(
                null, com.android.internal.R.styleable.AlertDialog, com.android.internal.R.attr.alertDialogStyle, 0);

针对R.attr.alertDialogStyle

pateo@pateo-B86N53X:/work/project/f0400s/frameworks/base/core/res$ grep -r "alertDialogStyle" ./
./res/values/attrs.xml:        <attr name="alertDialogStyle" format="reference" />
./res/values/attrs.xml:        <attr name="dlsalertDialogStyle" format="reference" />
./res/values/public.xml:  <public type="attr" name="alertDialogStyle" id="0x0101005d" />
./res/values/themes.xml:        <item name="alertDialogStyle">@android:style/AlertDialog</item>
./res/values/themes.xml:        <item name="dlsalertDialogStyle">@android:style/DlsAlertDialog</item>
pateo@pateo-B86N53X:/work/project/f0400s/frameworks/base/core/res$ 
pateo@pateo-B86N53X:/work/project/f0400s/frameworks/base/core/res$ 

找到styles.xml文件里面的AlertDialog


    <style name="AlertDialog">
        <item name="fullDark">@android:drawable/popup_full_dark</item>
        <item name="topDark">@android:drawable/popup_top_dark</item>
        <item name="centerDark">@android:drawable/popup_center_dark</item>
        <item name="bottomDark">@android:drawable/popup_bottom_dark</item>
        <item name="fullBright">@android:drawable/popup_full_bright</item>
        <item name="topBright">@android:drawable/popup_top_bright</item>
        <item name="centerBright">@android:drawable/popup_center_bright</item>
        <item name="bottomBright">@android:drawable/popup_bottom_bright</item>
        <item name="bottomMedium">@android:drawable/popup_bottom_medium</item>
        <item name="centerMedium">@android:drawable/popup_center_medium</item>    
    </style>



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值