解决方案 »
- 求助,用模拟器运行启动android应用,启动时报应用的外部jar找不到,Could not find class 'com.mapabc.mapapi.Geo
- 怎样在我的应用中关闭音乐播放器?
- Android系统自带的谷歌输入法分页问题
- 继续请教游戏开发中的问题:大家有什么好的方法来解决不同硬件的音频匹配问题吗?
- 关于Android编辑框的问题~
- android 4.0.3自己写软件无法访问网络
- android layout布局 多机型适配有几种思路?能不能从layout本身设计下手?
- 通过nexus4开发蓝牙4.0
- 请教关于监听蓝牙耳机点击按键的广播
- 想要进行android 数据库完成信息注册 有姓名 头像 性别
- Gallery问题,求指教
- imageview自定义控件的思路求寻
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/play_press" />
<item android:state_focused="true" android:drawable="@drawable/play_press" />
<item android:drawable="@drawable/play" />
</selector>
然后button的background设置为上面的xml就可以了
1、自定义背景图片
在通常情况下,为"布局","控件"等view设置设置背景,渐变或者有一个特殊等效果都是采用图片和颜色, 但是图片可能会面临被拉伸的风险(也可以9.png来处理解决), 单纯使用颜色要是现实特殊效果难以实现。所以当你想为你的应用是现在炫丽的效果时间, shope是你当仁不让的选择。
下面总结一下Shape的所有子属性:
gradient -- 对应颜色渐变。 startcolor、endcolor就不多说了。 android:angle 是指从哪个角度开始变。
solid -- 填充。
stroke -- 描边。
corners -- 圆角。
下面是一个应用实例<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#ffffffff"
android:centerColor="#FE8B1A"
android:endColor="#ffcccccc"
angle="270"
android:centerX="0.5"
android:centerY="0.5"
/>
<padding android:left="7dp"
android:top="7dp"
android:right="7dp"
android:bottom="7dp"/>
<corners android:radius="4dp"/>
</shape>
<!--
shape 节点配置的是图形的形式,主要包括方形、圆形等,上边代码为方形,
gradient 节点主要配置起点颜色、终点颜色及中间点的颜色、坐标、渐变效果
(0,90,180从左到右渐变,270从上到下渐变)默认从左到右
padding 节点主要配置上下左右的间距
corners节点配置四周园脚的半径
--> 这个以shape节点为根节点的xml文件就相当于一个drawble文件夹下的图片,可以作为背景或者被背景选择器引用。 2、背景选择器。2楼那个就不错。