Button详解

来源:互联网 发布:photoshop cc mac微盘 编辑:程序博客网 时间:2024/06/05 22:58

Button认知

public class Button extends TextView java.lang.Object   ↳    android.view.View   ↳    android.widget.TextView       ↳    android.widget.Button

使用详解

Button设置字体颜色
主要是调用Button.setTextColor();进行颜色设置。
Button.setTextColor(Android.graphics.Color.RED);//系统自带的颜色类
Button.setTextColor(0xffff00ff);//颜色值
Button.setTextColor(this.getResources().getColor(R.color.red));//通过获得资源文件进行设置

Button setTextColor()参数调用分析

常用实现效果

装载自:Android自定义Button背景色,弧度 详细内容请参看原作者。

<selector    xmlns:android="http://schemas.android.com/apk/res/android">    <!-- pressed -->    <item android:state_pressed="true" >        <shape  android:shape="rectangle">            <gradient                android:startColor="#ff8c00"                android:endColor="#ff8c00"                android:angle="270" />                       <corners                android:radius="4dp" />        </shape>    </item>   <!-- focus -->   <item android:state_focused="true" >        <shape>            <gradient                android:startColor="#ffc2b7"                android:endColor="#ffc2b7"                android:angle="270" />                        <corners                android:radius="4dp" />        </shape>    </item><!-- default -->    <item>                <shape>            <gradient                android:startColor="#d0d0d0"                android:endColor="#d0d0d0"                android:angle="0" />            <corners                android:radius="4dp" />        </shape>    </item></selector>
0 0
原创粉丝点击