如何使用XML或使用Java来改变一个按钮的形状? [英] How to change a button's shape using xml or using java?

查看:207
本文介绍了如何使用XML或使用Java来改变一个按钮的形状?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想打一个自定义的按钮形状,如何做到这一点?

I want to make a custom button with shape, how to do this?

推荐答案

这是样品钮扣这是椭圆形状。该梯度表示,随着角度的起始ñ结束颜色。四角为椭圆shape..Try这个..提到这一点在按钮的背景 Android的名称 XML :后台=@可绘制/样品 .Save在XML中的绘制

This is the sample button which is of oval shape.. The gradient says the start n end color along with the angle. corners for the oval shape..Try this.. Mention the name of this xml in button background android:background="@drawable/sample".Save the xml in drawable.

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient
        android:startColor="#302226"
        android:endColor="#6D7B8D"
        android:angle="45"/>
    <padding android:left="6dp"
        android:top="6dp"
        android:right="6dp"
        android:bottom="6dp" />
    <corners android:radius="30dp" />

</shape>

另外,请查阅此链接的自定义按钮。

这篇关于如何使用XML或使用Java来改变一个按钮的形状?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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