2016-06-30 44 views
1

我想建立3种不同的颜色,如附加的图像背景中的按钮,我不知道怎么做,与形状Android的形状按钮剥离

enter image description here

谢谢你的帮助。

+4

为什么不使用图像作为backgorund? –

+0

你想在这个BG上面按钮吗? –

+0

@LucaNicolett与图像我必须适应它到每个屏幕,形状是更好的表演 – nabenzine

回答

0

使用的ImageButton和使用上面的图像作为按钮的背景:

<ImageButton 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:src="@drawable/YOUR_BTN_IMG"/> 
+0

*如何做形状* –

+0

谢谢Drv,但我想要做到这一点与形状 – nabenzine

0

1日做出与BG1名绘制文件夹中的XML文件,并把这段代码

<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle"> 
    <gradient 
     android:angle="90" 
     android:centerColor="#4CAF50" 
     android:endColor="#2E7D32" 
     android:startColor="#b5e7b7" 
     android:type="linear" /> 
</shape> 

比以往任何时候你想去的地方它使用像

<ImageButton 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:src="@drawable/bg1"/> 

这里你改变角度,开始结束和中心的颜色根据你requiremen t

+0

谢谢,其实我不想使用渐变,我只需要3种颜色,也许我需要创建3个形状,但我不知道如何使他们对角线 – nabenzine

+0

只是角度45或135所以它变成对角线 –

+0

我已经试过了,它给出了很多没有条纹的渐变色,我只需要3种剥离颜色, – nabenzine