UI:使View背景逐渐变暗的方法
2015-10-12 15:58
267 查看
使用View 的 setAlpha(int alpha);
代码
xml:
其实就是将当前view 的透明度放低, 从而显示出ViewGroup的背景颜色
代码
setContentView(R.layout.activity_alpha_view); SeekBar seekBar = (SeekBar) findViewById(R.id.seekbar); seekBar.setMax(100); final LinearLayout ll = (LinearLayout) findViewById(R.id.rl); seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { @Override public void onStopTrackingTouch(SeekBar seekBar) { } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { ll.setAlpha(progress * 1.0f / 100); } });
xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="#333333"> <SeekBar android:id="@+id/seekbar" android:layout_width="match_parent" android:layout_height="wrap_content"/> <LinearLayout android:id="@+id/rl" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="#f0f0f0"> </LinearLayout> </LinearLayout>
其实就是将当前view 的透明度放低, 从而显示出ViewGroup的背景颜色
相关文章推荐
- BlueDroid 蓝牙启动流程分析
- Hdu 5496 Beauty of Sequence (组合数)
- zoj 3911 Prime Query (ZOJ Monthly, October 2015 - I)
- 关于UITableView的section最后一个分割线的优化
- easyui表单提交,后台获取不到值
- When START-OF-SELECTION is Not Required
- Request获取url各种信息的方法
- iOS开发笔记-Autolayout自动布局与UIView动画
- id to load is required for loading----id被要求加载exception
- Flume学习9_log4j:ERROR setFile(null,true) call failed产生的一个原因
- UI-UIView
- The request sent by the client was syntactically incorrect (). 的某个解决办法
- jsp中国文字形式提交,request对象获取乱码
- iOS仿京东分类菜单之UICollectionView内容
- UVA-1612 Guess (贪心)
- Pop Sequence
- 关于UITableView多余分割线的优化
- 哈希+前缀和 hdu5496 Beauty of Sequence
- (ArcGIS API For Silverlight )QueryTask 跨层查询,和监控完整的查询!
- AdapterView类mBlockLayoutRequests、mInLayout变量简介