创建自定义复合按钮栏 [英] Creating a Custom Compound Button Bar

查看:163
本文介绍了创建自定义复合按钮栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要创建一个定制的复合按钮栏控制Android中像一个的此处。要创建一个这样的按钮栏,我想延伸的LinearLayout,并添加我的按钮吧。该按钮有一个黑色的背景,但有一个渐变填充;我并不热衷于使用PNG图片,因为这些按钮的颜色可以在运行时更改。

I have to create a custom compound button bar control in Android like the one here. To create a button bar like this, I am thinking of extending a LinearLayout and add my buttons to it. The buttons have a black background but with a gradient fill; I am not keen on using PNGs since the color of the buttons can change at runtime.

我怎样才能在Android的类似的效果?

How can I get similar effect in Android?

感谢。

推荐答案

u必须使用的ImageView的按钮。

u have to use imageview as button.

设置两个图像视图,你可以改变颜色的按钮

set two image view you can change color the button

使用xml文件到的ImageView的SRC像

use xml file to src of that imageview like

<?xml version="1.0" encoding="UTF-8"?>

<selector xmlns:android="http://schemas.android.com/apk/res/android">

<item android:state_pressed="false"
    android:drawable="@drawable/back_normal" />

<item android:state_pressed="true"
    android:drawable="@drawable/back_pressed" />

</selector>

有关gredient风格。

for gredient style.

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient android:angle="90" android:startColor="#663300"
    android:centerColor="#330000"
    android:endColor="#330000"/>
</shape>

完蛋了。

这篇关于创建自定义复合按钮栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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