android透明值
㈠ android怎么将弹出窗口透明
1. 在res/values 下建立color.xml
<resources>
<color name="transparent_background">#80ffffff</color>
</resources>
PS: #80是透明度的值(即80%透明),ffffff是颜色值(为黑色)
2. 在res/values下建立style.xml
<resources> <style name="Transparent" parent="android:style/Theme.Dialog"> <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>
PS: parent="android:style/Theme.Dialog" 是将activity设置为弹出式窗口
3. 在AndroidManifest.xml中找到要弹出的activity,加入theme:
<activity android:name="ActivityName" android:theme="@style/Transparent" />完成上面设置后,你的activity就已经是透明的了,但是该Activity中的控件还没有透明,如果还需要控件透明,则需要在该activity的代码中加入如下代码:
//设置activity中的控件透明 Window window = getWindow(); WindowManager.LayoutParams wl = window.getAttributes(); wl.flags = WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON; wl.alpha=0.95f;//设置透明度,0.0为完全透明,1.0为完全不透明 window.setAttributes(wl);
㈡ 怎样将android控件背景设置成透明
1、打开安卓的配置文件。
2、只需要在配置文件中把需要设置为透明的activity的样式设置为android:theme="@android:style/Theme.Translucent"
3、这样就可以把背景设置为透明。
㈢ android怎么改变textview透明度
textview1.setTextColor(Color.argb(255,0,255,0));//文字透明度
最关键部分,设置字体透明度argb(Alpha,R,G,B)
㈣ android 怎么设置view 透明
在布局文件中设置属性:android:background="#00FFFFFF";
00是表示透明度的,设置成00就是完全透明,FFFFFF是白色的十六位码
㈤ android编程如何把现有的背景图片设置成透明的
方法一:
只要在配置文件内activity属性配置内加上
android:theme="@android:style/Theme.Translucent"
就好了。
这样就调用了android的透明样式!
方法二:
先在res/values下建colors.xml文件,写入:
<?xmlversionxmlversion="1.0"encoding="UTF-8"?>
<resources>
<colornamecolorname="transparent">#9000</color>
</resources>
这个值设定了整个界面的透明度,为了看得见效果,现在设为透明度为56%(9/16)左右。
㈥ 请教android怎么让控件背景透明
以Android Studio为例,步骤如下:
1、直接打开相关窗口,在Android-app-res-layout的空白处点击鼠标右键并选择New-Layoutresource file。
㈦ Android 透明度设置详解
格式:
android:background="#XXxxxxxx"(颜色可以写在color中)
说明:半透明颜色值不同于平时使用的颜色,半透明颜色值共8位,前2位是透明度,后6位是颜色。也就是说透明度和颜色结合就可以写出各种颜色的透明度。下面是透明度说明表,供大家参考。
部分透明度示例:
setAlpha()的括号中可以填0–255之间的数字。数字越大,越不透明。
注意点:
在5.0以上系统时,有些机型会出现莫名其妙的颜色值不起作用,变成透明了,也就是用此方法会导致其他共用一个资源的布局(例如:@color/white)透明度也跟着改变。比如text用上述方法设置成透明后,项目中,其他用到text颜色值的控件,都变成透明了。
原因:在布局中多个控件同时使用一个资源的时候,这些控件会共用一个状态,例如ColorState,如果你改变了一个控件的状态,其他的控件都会接收到相同的通知。这时我们可以使用mutate()方法使该控件状态不定,这样不定状态的控件就不会共享自己的状态了。
android:alpha的值为0~1之间的数。数字越大,越不透明。1表示完全不透明,0表示完全透明。
说道Activity透明,发现网上的基本上都已经过时,在有v7以上的控件都无法实现,均会报错
所以如若你的布局xml文件有 support-V7 上的控件的话,<style name="translucent">里的name要前要添加 AppTheme,如:
㈧ android 怎么给一块区域设置背景半透明
activity的背景透明,只需在只要在配置文件内activity属性配置内加上android:theme="@android:style/Theme.Translucent"就好了。
但是想要多方面的设置theme的话,就要在values里设置风格先:
加透明:
先在res/values下建colors.xml文件,写入:
<?xmlversionxmlversion="1.0"encoding="UTF-8"?>
<resources>
<colornamecolorname="transparent">#9000</color><!--透明度-->
</resources>
这个值设定了整个界面的透明度,为了看得见效果,现在设为透明度为56%(9/16)左右。
透明度可以用#9000值调,将这个值(ARGB)改变,就会有不同效果的透明度。
再在res/values/下建styles.xml,设置程序的风格
<?xmlversionxmlversion="1.0"encoding="utf-8"?>
<resources>
<stylenamestylename="Transparent">
<item name="android:windowBackground">@color/transparent</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowAnimationStyle">@+android:style/Animation.Translucent</item>
</style>
</resources>
加了@+android:style/Animation.Translucent这句的时候就会显示出此activity会有动画切换效果
最后一步,把这个styles.xml用在相应的Activity上。即在AndroidManifest.xml中的任意标签中添加 android:theme="@style/transparent"
如果要设置所有的activity都使用这个风格,就把这句标签语句添加在中。
㈨ android标题栏透明度渐变
<alpha>标签为alpha透明度节点
android:fromAlpha="1.0" 设置动画起始透明度为1.0 表示完全不透明
android:toAlpha="0.0"设置动画结束透明度为0.0 表示完全透明
也就是说alpha的取值范围为0.0 - 1.0 之间
这个动画布局设置动画从完全不透明渐变到完全透明。
view plain
<?xml
version="1.0"
encoding="utf-8"?>
<alpha
xmlns:android="http://schemas.android.com/apk/res/android"
android:fromAlpha="1.0"
android:toAlpha="0.0"
android:repeatCount="infinite"
android:ration="2000">
</alpha>
代码实现
view plain
import android.app.Activity;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
public
class AlphaActivity extends Activity {
/**显示动画的ImageView**/
ImageView mImageView = null;
/**透明动画**/
Animation mAnimation = null;
@Override
public
void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.translate);
/**拿到ImageView对象**/
mImageView = (ImageView)findViewById(R.id.imageView);
/**加载透明动画**/
mAnimation = AnimationUtils.loadAnimation(this, R.anim.alpha);
/**播放透明动画**/
mImageView.startAnimation(mAnimation);
}
}
㈩ android 半透明效果怎么实现的
设置透明效果 大概有三种
1、用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" />
2、用ARGB来控制
Java代码
半透明<Button android:background="#e0000000" />
透明<Button android:background="#00000000" />
3、设置alpha
Java代码
View v = findViewById(R.id.content);//找到你要设透明背景的layout 的id
v.getBackground().setAlpha(100);//0~255透明度值