当前位置: 首页 > 编程笔记 >

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

皇甫飞宇
2023-03-14
本文向大家介绍Android设置Activity背景为透明style的简单方法(必看),包括了Android设置Activity背景为透明style的简单方法(必看)的使用技巧和注意事项,需要的朋友参考一下

方法一:

通过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的简单方法(必看)全部内容了,希望大家多多支持小牛知识库~

 类似资料:
  • 本文向大家介绍android如何设置Activity背景色为透明色,包括了android如何设置Activity背景色为透明色的使用技巧和注意事项,需要的朋友参考一下 一直听说透明效果的activity,到底长啥样呢?来张图看看,上面这个白色背景的就是 方法一 在res/values/styles.xml,设置Activity的样式 color Manifest.xml中添加 这样就给你的acti

  • 我想用透明的背景显示警报对话框。我的警报对话框代码为: 我的背景图像包含圆形的角,但不幸的是,流行是以矩形白色背景出现的。任何身体plz建议我的想法。提前谢谢。

  • 本文向大家介绍Android编程实现设置按钮背景透明与半透明及图片背景透明的方法,包括了Android编程实现设置按钮背景透明与半透明及图片背景透明的方法的使用技巧和注意事项,需要的朋友参考一下 本文实例讲述了Android编程实现设置按钮背景透明与半透明及图片背景透明的方法。分享给大家供大家参考,具体如下: Button或者ImageButton的背景设为透明或者半透明: 半透明 透明 颜色和不

  • 我正在尝试移除(或者只是设置为不可见)我的JList的背景和边框。 当我在它上设置透明颜色时,我的JList背景保持白色。 这是我的自定义jcombox呈现器类: 我尝试在每个组件上放置和,但是没有好的结果。 一个解决方案是调整列表中图像的大小,但我的图像不是矩形的,所以列表背景的角是可见的。

  • 通过使用启用透明背景功能,可以使用自定义图片作为背景。 controller.setTransparentBackground( true );

  • 如何将背景颜色设置为透明