当前位置: 移动技术网 > IT编程>移动开发>Android > Android设置Activity背景为透明style的简单方法(必看)

Android设置Activity背景为透明style的简单方法(必看)

2019年07月24日  | 移动技术网IT编程  | 我要评论

风车动漫网站,绘画全本金瓶梅,母亲的战争片尾曲

方法一:

通过theme.translucent

@android:style/theme.translucent
@android:style/theme.translucent.notitlebar
@android:style/theme.translucent.notitlebar.fullscreen

只需要在manifest中需要透明的activity内设置theme为以上任意一个就可以了

<activity 
  android:name="com.vixtel.simulate.mainapp" 
  android:configchanges="keyboardhidden|orientation" 
  android:label="@string/app_name" 
  android:screenorientation="portrait" 
  android:theme="@android:style/theme.translucent.notitlebar" > 
  <intent-filter> 
    <action android:name="android.intent.action.main" /> 
 
    <category android:name="android.intent.category.launcher" /> 
  </intent-filter> 
</activity> 

方法二:

自定义style,就像自定义dialog的style一样,在res-values-color.xml中添加透明颜色值:

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
 
  <color name="transparent">#0000</color> 
 
</resources> 

在res-values-styles.xml中添加如下:

<style name="mytransparent"> 
  <item name="android:windowbackground">@color/transparent</item> 
  <item name="android:windownotitle">true</item> 
  <item name="android:windowistranslucent">true</item> 
  <item name="android:windowanimationstyle">@android:style/animation.translucent</item> 
</style> 

在manifest中中需要透明的activity内设置theme为我们自定义的即可

android:theme="@style/mytransparent"

运行程序后,就全透明了,看得见背景下的所有东西可以却都操作无效。

以上就是小编为大家带来的android设置activity背景为透明style的简单方法(必看)全部内容了,希望大家多多支持移动技术网~

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网