如何设置对话框按钮颜色 [英] how to set button color in dialog box

查看:200
本文介绍了如何设置对话框按钮颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了具有接受和拒绝按钮的对话框,但按钮的颜色是默认的颜色。谁能提供code设置在绿色和红色按钮的颜色。

i have created a dialog box which has "accept" and "reject" buttons, but the color of the button is in default color. can anyone provide the code to set the color of the buttons in green and red.

推荐答案

通过创建一个自定义绘制..例如..

By creating a custom drawable.. for example..

button.setBackgroundResource(R.drawable.custom_button);

custom_button.xml

custom_button.xml

<?xml version="1.0" encoding="utf-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > 
<item> 
  <shape android:shape="rectangle">
    <corners android:radius="8dip" />  
        <stroke android:width="1dp" android:color="your color" /> 
        <solid android:color="@color/ceruleo" /> 
    </shape> 
 </item> 

 <item android:top="1dp" android:bottom="1dp" android:left="1dp" android:right="1dp">  
  <shape android:shape="rectangle"> 
    <corners android:radius="8dip" /> 
        <stroke android:width="1dp" android:color="your color" /> 
        <solid android:color="@color/ceruleo" /> 
    </shape> 
 </item> 

 </layer-list> 

这篇关于如何设置对话框按钮颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆