美文网首页
AlertDialog radiobutton 自定义主题

AlertDialog radiobutton 自定义主题

作者: 念念不忘_2016 | 来源:发表于2021-07-22 14:37 被阅读0次

开发中经常遇到这种弹窗,系统颜色往往不合适,于是我们使用自定义style方式进行设置

最终效果
      String[] cameraNames = new String[]{"camera0","camera1"};
        AlertDialog.Builder alertBuilder = new AlertDialog.Builder(getContext(),R.style.alterAialogCustom);
        alertBuilder.setSingleChoiceItems(cameraNames, checkedItemIndex, (dialogInterface, i) -> {
            dialogInterface.dismiss();
        });
        alertBuilder.setPositiveButton(getString(R.string.cancel), (dialogInterface, i) -> dialogInterface.dismiss());
      AlertDialog alertDialog = alertBuilder.create();
      alertDialog.show();
        <!--    自定义alterDialog 样式-->
    <style name="alterAialogCustom" parent="ThemeOverlay.AppCompat.Dialog.Alert">
        <!--        <item name="android:textColor">#00FF00</item>-->
        <!--        <item name="android:typeface">monospace</item>-->
        <!--        <item name="android:textSize">10sp</item>-->
        <!--        radiobutton 正常颜色-->
        <item name="colorControlNormal">#61000000</item>
        <!--        radiobutton 选中颜色-->
        <item name="colorControlActivated">#1B6FE5</item>
    </style>

相关文章

网友评论

      本文标题:AlertDialog radiobutton 自定义主题

      本文链接:https://www.haomeiwen.com/subject/zenemltx.html