原生Dialog字体颜色等属性

 

AlertDialog.Builder builder = new AlertDialog.Builder(VideoActivity.this);
builder.setTitle("温馨提示");
builder.setMessage("当前是运营商网络,继续观看将消耗较多流量,产生高额流量费,是否继续观看");
builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {
        finish();
    }
});
builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                //视频播放
                jzVideoPlayerStandard.startVideo();
            }
        });
    }
});
AlertDialog dialog = builder.create();
if(hasWindowFocus()) {
    dialog.show();
    daiogbug(dialog);
}
try {
    Field mAlert = AlertDialog.class.getDeclaredField("mAlert");
    mAlert.setAccessible(true);
    Object mAlertController = mAlert.get(dialog);

    Field mMessage = mAlertController.getClass().getDeclaredField("mMessageView");
    mMessage.setAccessible(true);
    TextView mMessageView = (TextView) mMessage.get(mAlertController);
    mMessageView.setTextColor(Color.GRAY);//更改内容的颜色

} catch (IllegalAccessException e) {
    e.printStackTrace();
} catch (NoSuchFieldException e) {
    e.printStackTrace();
}

try {
    Field mAlert = AlertDialog.class.getDeclaredField("mAlert");
    mAlert.setAccessible(true);
    Object alertController = mAlert.get(dialog);

    Field mTitleView = alertController.getClass().getDeclaredField("mTitleView");
    mTitleView.setAccessible(true);

    TextView title = (TextView) mTitleView.get(alertController);
    title.setTextColor(Color.BLACK);//更改标题的颜色

} catch (NoSuchFieldException e) {
    e.printStackTrace();
} catch (IllegalArgumentException e) {
    e.printStackTrace();
} catch (IllegalAccessException e) {
    e.printStackTrace();
}

//更改按钮颜色
dialog.getButton(dialog.BUTTON_NEGATIVE).setTextColor(Color.BLACK);
dialog.getButton(dialog.BUTTON_POSITIVE).setTextColor(Color.BLACK);
223916_bL9y_2663968.jpg
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值