以编程方式创建有光泽的3d按钮 [英] Programmatically create glossy 3d button

查看:55
本文介绍了以编程方式创建有光泽的3d按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Google上进行了搜索,但是找不到关于如何在android中创建看起来像有光泽的闪亮按钮并带有轻微3d效果的按钮的好提示.参见图片:

I have googled it already but can't find a good hint on how to create buttons in android that look like glossy shiny buttons with a slight 3d effect. See pic:

如何以编程方式执行此操作?

How can I programmatically do this?

推荐答案

创建这样的选择器,并将其应用于按钮可绘制对象.根据您的要求对其进行自定义:

Create a selector like this and apply it to your button drawable. Customize it to your requirements:

 <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
        <item>        
            <shape>
                <gradient
                    android:endColor="#0905FB"
                    android:startColor="#9796FD"
                    android:angle="270" />
                <stroke
                    android:width="3dp"
                    android:color="#65655B" />
                <corners
                    android:radius="3dp" />
                <padding
                    android:left="10dp"
                    android:top="10dp"
                    android:right="10dp"
                    android:bottom="10dp" />
            </shape>
        </item>
        <item android:state_focused="true" >
           ...
           ...
           ...
        </item>

       <item android:state_pressed="true" >
         ...
         ...
         ...
       </item>
   </selector>

这篇关于以编程方式创建有光泽的3d按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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