2015-10-03 31 views
0

即时通讯新的Android工作室,我想定制我的按钮,我创建了一个新的XML文件的文件夹drawable,我但这个代码(注意:我看到了这个代码在另一个问题):Android工作室上的自定义按钮

<?xml version="1.0" encoding="UTF-8"?> 
<shape 
xmlns:android="http://schemas.android.com/apk/res/android"> 
<stroke 
    android:width="1dip" 
    android:color="#ffffff"/> 
<solid 
    android:color="#95865F"/> 
<corners 

    android:topRightRadius="1dp" 
    android:bottomRightRadius="1dp" 
    android:topLeftRadius="1dp" 
    android:bottomLeftRadius="1dp" 
    /> 

<padding 
    android:left="1dp" 
    android:right="1dp" 
    android:top="1dp" 
    android:bottom="1dp"/> 
</shape> 
上MUY按钮化背景选项

此我把“@绘制/ roundedbutton”这是我的XML文件的名称和位置,也为我在其他帖子看到,公交车在设计窗口,我有这样的文字上

布局编辑器中的图形预览可能不准确

和我的按钮现在是彩色咖啡和丑陋! 我该怎么办?

回答

0

您的按钮的颜色更多信息由这个属性在你的XML

<solid 
    android:color="#95865F"/> 

定义颜色本身是十六进制格式RRGGBB。如果您不喜欢这种颜色,只需更改该值即可。例如。 #FF0000将使你的按钮完全红色

+0

是的,但是当我把它放在我的代码颜色doest改变,我认为这是因为代码有问题 –

0

为了设置为你的按钮输入新的背景,你可以使用:

<Button android:layout_widt="wrap_content" android:layout_height="wrap_content" android:background="@drawable/yourfile"/> <!-- this is for setting the background of a button --> 但这只是冰山的顶端。 您也可以使用.setText();方法来设置自定义文本到您的按钮。 在这里 http://developer.android.com/reference/android/widget/Button.html