Android设置透明、半透明等效果
Java代码
android:background="@android:color/transparent"
Java代码
<Button android:background="@android:color/transparent"
android:text="@+id/Button01"
android:id="@+id/Button01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ffffff" />
半透明<Button android:background="#e0000000" />
透明<Button android:background="#00000000" />
View v = findViewById(R.id.content);//找到你要设透明背景的layout 的id
v.getBackground().setAlpha(100);//0~255透明度值
1 |
WindowManager.LayoutParams lp=getWindow().getAttributes(); |
2 |
lp.alpha=0.3f; |
3 |
getWindow().setAttributes(lp); |
设置黑暗度
1 |
WindowManager.LayoutParams lp=getWindow().getAttributes(); |
2 |
lp.dimAmount=0.5f; |
3 |
getWindow().setAttributes(lp); |
4 |
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); |
设置背景模糊
1 |
getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND, |
2 |
WindowManager.LayoutParams.FLAG_BLUR_BEHIND); |
|
1
2 3 4 5 6 7 8 9 10 11 12 |
<resources>
<style name="Transparent"> <item name="android:windowBackground"> @color/transparent_background </item> <item name="android:windowNoTitle">true</item> <item name="android:windowIsTranslucent">true</item> <item name="android:windowAnimationStyle"> @+android:style/Animation.Translucent </item> </style> </resources> |
|
1
2 3 4 5 6 7 |
<?xml version="1.0" encoding="utf-8"?>
<resources> <color name="transparent_background">#50000000</color> </resources> //注意: //color.xml的#5000000前两位是透明的效果参数从00--99(透明--不怎么透明), //后6位是颜色的设置 |
|
1
2 3 4 |
<activity
android:name=".TransparentActivity" android:theme="@style/Transparent"> </activity> |
|
1
2 3 4 5 |
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); setTheme(R.style.Transparent); setContentView(R.layout.transparent); } |
Android设置透明、半透明等效果的更多相关文章
- android设置view透明度的效果
android设置view透明度的效果 推荐textView.setBackgroundColor(Color.TRANSPARENT); 第一种方法:在xml文件中设置背景颜色. andro ...
- android设置背景半透明效果
1.Button或者ImageButton的背景透明或者半透明 半透明:<Button android:background="#e0000000"···> 透明:&l ...
- 第三十九篇、NavBar动态隐藏、设置透明、毛玻璃效果
1.动态隐藏 - (void)viewDidLoad { [super viewDidLoad]; if ([self respondsToSelector:@selector(automatical ...
- Android课程---Android设置透明效果的三种方法(转)
1.使用Android系统自带的透明效果资源 <Button android:background="@android:color/transparent"/> ...
- Android设置透明状态
xml中: android:background="@android:color/transparent" 半透明: android:background="#e0000 ...
- android设置透明状态栏
先是半透明效果(两种方法): 第一种(简单): //直接将下面的代码放在activity中的setContentView(R.layout.activity_main);中之前就行了 if (Buil ...
- Android实现透明的颜色效果
android Button或者ImageButton背景透明状态设置 设置Button或ImageButton的背景为透明或者半透明 半透明< Button android:backgroun ...
- Android实现透明的颜色效果(zz)
android Button或者ImageButton背景透明状态设置 设置Button或ImageButton的背景为透明或者半透明 半透明< Button android:backgroun ...
- Android设置透明状态栏和透明导航栏
Android透明状态栏只有在4.4之后有. 在代码中加入下面几行代码即可实现
随机推荐
- C++资料大全
本文内容源自GitHub<Awesome C/C++>. 关于 C++ 框架.库和资源的一些汇总列表,由 fffaraz 发起和维护. 内容包括:标准库.Web应用框架.人工智能.数据库. ...
- Windows下使用批处理设置IP地址,DNS
自动获取IP地址: echo 本地连接 改成你想要改的连接名 比如 无线网络连接set cname=本地连接 echo %cname% 正在设置自动获得IP地址,请稍等...... netsh int ...
- js实现windows扫雷(jquery)
<html> <head> <meta http-equiv="Content-Type" content="text/html; char ...
- linux下进程、端口号相互查看方法
linux下通过进程名查看其占用端口: 1.先查看进程pid ps -ef | grep 进程名 2.通过pid查看占用端口 netstat -nap | grep 进程pid 例:通过nginx进程 ...
- activiti自定义流程之自定义表单(一):环境配置
先补充说一下自定义流程整个的思路,自定义流程的目的就是为了让一套代码解决多种业务流程,比如请假单.报销单.采购单.协作单等等,用户自己来设计流程图. 这里要涉及到这样几个基本问题,一是不同的业务需求, ...
- PHP解码unicode编码中文字符代码示例
在抓取某网站数据,结果在数据包中发现了一串编码的数据:"......\u65b0\u6d6a\u5fae\u535a......", 这其实是中文被unicode编码后了的数据,想 ...
- .net EntityFramework用法探索系列 1
EntityFramework用法探索系列 (一)DatabaseFirst (二)CodeFirst (三)CodeFirst流畅API (四)Repository和UnitOfWork (五)引入 ...
- IO - IOUtils
Commons IO is a library of utilities to assist with developing IO functionality. There are four main ...
- CF 161D Distance in Tree 树形DP
一棵树,边长都是1,问这棵树有多少点对的距离刚好为k 令tree(i)表示以i为根的子树 dp[i][j][1]:在tree(i)中,经过节点i,长度为j,其中一个端点为i的路径的个数dp[i][j] ...
- gridView--GridView关于间距的属性值介绍
android:columnWidth 设置列的宽度.关联的方法为:setColumnWidth(int) android:gravity 设置此组件中的内容在组件中的位置.可选的值有:top.b ...