----------------------------------------------------------
一般指EditText/Spinner等的外观变化

一、使用shape实现渐变效果
(1)创建新的drawable的xml文件
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<gradient android:startColor="#FFFF0000" android:endColor="#80FF00FF"
android:angle="270"/>
<padding android:left="50dp" android:top="20dp"
android:right="7dp" android:bottom="7dp" />
<corners android:radius="8dp" />
</shape>
gradient 产生颜色渐变 android:angle 从哪个角度开始变 貌似只有90的整数倍可以
android:shape="rectangle" 默认的也是长方形
corners表示是有半径
(2)设置android:background属性
android:background="@drawable/share_background"
--------------------------------------------------------------------------------------------
一般是指字体的大小、颜色等样式


二.Style(一般是指字体的大小、颜色等样式 ) (如TextView/EditText)
灵活使用styles.xml
(1)在res/values目录下新建一个style.xml,增加<resource>根节点
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="SpecialText" parent="@style/Text">
<item name="android:textSize">18sp</item>
<item name="android:textColor">#008</item>
</style>
<style name="button_style">
<item name="android:textStyle">bold</item>
<item name="android:textColor">#FFFFFFFF</item>
<item name="android:layout_width">100.0dip</item>
</style>
</resources>
(2)设置style属性
<EditText id="@+id/text1"
style="@style/SpecialText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello, World!" />
现在这个EditText组件的所表现出来的风格就为我们在上边的XML文件中所定义的那样。
(补充:主题(theme)和style一样,也是在style.xml内申明,也是同样方式引用,不同的是通过在AndroidManifest.xml中定义的<application>和<activity>元素中使用到整个程序或者某个activity,但是主题不能用到某一个单独的view里。)
---------------------------------------------------------------------------------------------------------------------------------
这个主要判断焦点选中或者未选中时候的状态 背景颜色
3.自定义按钮显示效果
(1)在drawable中创建新的xml文件--mybutton.xml文件。
<item android:state_window_focused="false" android:drawable="@color/transparent" />
<!-- Even though these two point to the same resource, have two states so the drawable will invalidate itself when coming out of pressed state. 注意这句话-->
<item android:state_focused="true" android:state_enabled="false"
android:state_pressed="true"
android:drawable="@drawable/selector_background_disabled" />
<item android:state_focused="true" android:state_enabled="false"
android:drawable="@drawable/lselector_background_disabled" />
<item android:state_focused="true" android:state_pressed="true"
android:drawable="@drawable/selector_background_transition" />
<item android:state_focused="false" android:state_pressed="true"
android:drawable="@drawable/selector_background_transition" />
<item android:state_focused="true"
android:drawable="@drawable/selector_background_focus" />
</selector>
(2)在构造的layout中引用这个xml
<ImageButton
android:id="@+id/ImageButton01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/mybutton">
</ImageButton>

更多相关文章

  1. Android(安卓)NDK环境搭建
  2. Android高手进阶教程(五)之----Android(安卓)中LayoutInflater的
  3. Android系统权限和root权限
  4. 创建 Android(安卓)库
  5. Android(安卓)Studio(七):项目从Eclipse到Android(安卓)Studio迁
  6. Android使用FFmpeg(一)--编译ffmpeg
  7. Android(安卓)数据存储02之文件读写
  8. Android系统在超级终端下必会的命令大全(adb shell命令大全)
  9. 创建 cocos2d-x+lua for android 步骤

随机推荐

  1. Android中实现ListView滑动首字母提示 .
  2. 仿QQ android 实战(学习 android 先来个QQ
  3. Android测试之Monkey原理及源码分析(二)
  4. android linux 基础知识总结
  5. Android(安卓)Asynchronous Http Client
  6. Android(安卓)NDK 的学习之旅-----HelloW
  7. Android(安卓)网络权限配置
  8. material design 的android开源代码整理
  9. android开发专题系列-Android开发指南
  10. android打电话,发短信