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之后有. 在代码中加入下面几行代码即可实现
随机推荐
- lucene之排序、设置权重、优化、分布式搜索(转)
lucene之排序.设置权重.优化.分布式搜索(转) 1. 基本应用 using System;using System.Collections.Generic;using System.Text;u ...
- iMac一体机安装苹果和Win7双系统
前几天,有个客户说有一苹果的一体机,想装苹果和Win7双系统.约好了时间,带上工具就过去了.去的路上,用手机上网查了一下苹果电脑装双系统的过程.虽然以前也有给苹果的电脑安装过双系统,但次数不多而且时间 ...
- VirtualBox 下USB 设备加载的步骤及无法加载的解决办法
1. 将u盘插入电脑,在windows能够识别后,进入VirtualBox的选定要加载的虚拟机,选择设置——>选择usb设备项 2. 选择右边的第一或者是第二个图标,增加一个新的筛选器,第一个图 ...
- 【Android学习日记】
(一) Android 开发基础 1 Android平台的特性 1) 应用程序框架支持组建的重用和替换,包括打电话应用程序.文件管理器等. 2) Dalvik虚拟机专门为移动设备做了优化,Dalv ...
- 像学历史课本一样学习Perl
第一次接触Perl,还是2008年10月份的时候,当时因为项目重构,需要进行大量的文本操作,于是便拾起了以“文本操作为己任”的Perl语言.当然,带我入门的还是那本赫赫有名的The Llama Bo ...
- Linux下diff打补丁方法
tar zxvf php-5.2.14.tar.gz gzip -cd php-5.2.14-fpm-0.5.14.diff.gz | patch -d php-5.2.14 -p1
- js延迟加载,提升网页加载速度
JS延迟加载,简单例子,不多说: 代码如下: 程序代码 <script language="JavaScript" src="" id="my& ...
- OpenCV中Delaunay三角网算法例子
#include <opencv2/opencv.hpp> #include <vector> using namespace cv; using namespace std; ...
- CF577B Modulo Sum 好题
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...
- haxm intelx86加速模拟器的安装
http://blog.csdn.net/huang9012/article/details/18082601 如果安装了还出现 创建模拟器 选项 CPU/abi的时候还出现 no system im ...