动态设置Button、ImageView等组件在不同状态下的背景/前景显示效果。 扩展下的话可以前景/背景的显示效果可以使用网络图片。
来源:互联网 发布:董小飒电竞淘宝店 编辑:程序博客网 时间:2024/05/17 03:24
- /** 设置Selector。 */
- public static StateListDrawable newSelector(Context context, int idNormal, int idPressed, int idFocused,
- int idUnable) {
- StateListDrawable bg = new StateListDrawable();
- Drawable normal = idNormal == -1 ? null : context.getResources().getDrawable(idNormal);
- Drawable pressed = idPressed == -1 ? null : context.getResources().getDrawable(idPressed);
- Drawable focused = idFocused == -1 ? null : context.getResources().getDrawable(idFocused);
- Drawable unable = idUnable == -1 ? null : context.getResources().getDrawable(idUnable);
- // View.PRESSED_ENABLED_STATE_SET
- bg.addState(new int[] { android.R.attr.state_pressed, android.R.attr.state_enabled }, pressed);
- // View.ENABLED_FOCUSED_STATE_SET
- bg.addState(new int[] { android.R.attr.state_enabled, android.R.attr.state_focused }, focused);
- // View.ENABLED_STATE_SET
- bg.addState(new int[] { android.R.attr.state_enabled }, normal);
- // View.FOCUSED_STATE_SET
- bg.addState(new int[] { android.R.attr.state_focused }, focused);
- // View.WINDOW_FOCUSED_STATE_SET
- bg.addState(new int[] { android.R.attr.state_window_focused }, unable);
- // View.EMPTY_STATE_SET
- bg.addState(new int[] {}, normal);
- return bg;
- }
0 0
- 动态设置Button、ImageView等组件在不同状态下的背景/前景显示效果。 扩展下的话可以前景/背景的显示效果可以使用网络图片。
- ImageButton设置背景透明后,点击显示button按下效果
- android 根据button不同状态显示不同(背景)图片(background!!!!!)
- Android自定义View——可在背景图和前景图显示遮罩效果的ImageView
- [自用门户]介绍css中背景居中显示,介绍边框显示效果(可以试试去掉的效果)
- 设置button背景的半透明效果!!!
- Android基本组件——1.Button、ImageView等的按下效果
- ios状态栏颜色的设置(背景、前景)
- Button的背景使用selector图片无法显示的问题
- 将图片的说明文字显示在图片之上且背景半透明效果
- OSG 设置背景,前景
- OSG 设置背景,前景
- OSG 设置背景,前景
- 可以显示超大,长图片的ImageView
- unity_NGUI系统学习(四)_Atlas图集的创建和使用_Button触发状态还可以用图片做背景效果设定
- 状态栏的背景 前景和背景
- 一个可以实时显示进度的自定义view,类似于listview中音乐播放背景变化的效果
- Android动态封装圆角,按下效果的背景
- LeetCode之Balanced Binary Tree
- django client接口post请求
- 位运算简介及实用技巧(一):基础篇
- 自己做jQuery开源插件之二:数据校验插件
- 【C学习点滴】NULL是指针
- 动态设置Button、ImageView等组件在不同状态下的背景/前景显示效果。 扩展下的话可以前景/背景的显示效果可以使用网络图片。
- Codeforces Round #136 (Div. 2) C. Little Elephant and Problem
- android调用第三方地图(URI)
- 第一笔
- MySQL主从复制与读写分离
- 位运算简介及实用技巧(二):进阶篇(1)
- 位运算简介及实用技巧(三):进阶篇(2)
- UVa:1232 SKYLINE
- 【翻译】“PE文件格式”1.9版 完整译文(附注释)