android 按钮变化颜色
res/layout/activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" >


<Button
android:id="@+id/btn1"
android:text="123456"
android:layout_width="180dp"
android:layout_height="45dp"
android:layout_marginLeft="70dp"
android:background="@drawable/login_button_selector"
android:layout_marginTop="40dp"
android:textColor="@android:color/holo_red_light" />
</LinearLayout>


res/drawable/login_button_selector.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">


<item android:drawable="@drawable/clr_normal"
android:state_pressed="false"/>
<item android:drawable="@drawable/clr_pressed"
android:state_pressed="true"/>
</selector>




res/values/strings.xml
<resources>
<string name="app_name">testapp</string>


<string name="hello_world">Hello world!</string>
<string name="action_settings">Settings</string>


<drawable name="clr_normal">#D200D2</drawable>
<drawable name="clr_pressed">#FFFF37</drawable>
</resources>




public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}







更多相关文章

  1. TextInput 需要注意的点
  2. Android(安卓)颜色过渡计算
  3. Android(安卓)的res/values/colors自定义颜色列表和注释表及布局
  4. android RadioButton放大或者缩小
  5. Android之——史上最简单自定义开关按钮的实现
  6. Androidstudio开发button按钮的操作以及项目开发大致过程
  7. Android(安卓)TestView文本文字修改实例
  8. Android(安卓)实现颜色渐变的一个小 tip
  9. Android(安卓)LCD背景颜色和边框颜色的可控制

随机推荐

  1. 【移动开发】Android中Activity剖析
  2. 【Android那些高逼格的写法】Callable与
  3. 【转】Android开发者必须深入学习的10个
  4. android之计时器(Chronometer)的使用以及
  5. Android工程:引用另一个Android工程的方
  6. Android应用内搜索
  7. Android下屏幕适配
  8. 程序员滴无奈生活记(二)
  9. Android intent 传递对象以及返回刷新
  10. android WebView将新浪天气为我所用 ----