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"

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

时间: 2024-07-29 03:55:12

Android设置Activity背景为透明style的相关文章

android设置Activity背景色为透明的2种方法

android设置背景色为透明 方法一: 只要在配置文件内activity属性配置内加上 android:theme="@android:style/Theme.Translucent" 就好了. 这样就调用了android的透明样式! 方法二: 先在res/values下建colors.xml文件,写入: <?xmlversion="1.0"encoding="UTF-8"?> <resources> <color

CSS设置元素背景为透明

IE浏览器下设置元素css背景为透明: background-color: rgb(0, 0, 0); filter: alpha(opacity=20); 非IE浏览器下设置元素css背景为透明: background-color: rgba(0, 0, 0, 0.2); 兼容各类浏览器设置css背景为透明办法,即两者合并设置css: (ie 不支持 rgba,所以rgba不会起作用) background-color: rgb(0, 0, 0); filter: alpha(opacity=

Android 代码设置Activity 背景透明

当指定Activity 样式 Them.Dialog 时候 又不同意用XML 设置 Activity 的背景颜色的时候 用代码 this.getWindow().getDecorView().setBackgroundColor(Color.TRANSPARENT); 主意:代码写在 setContView();方法的后面.

android设置window背景透明的bug

今天解决了一个bug,在我们产品中的界面上快速点击某个控件(点击完要跳转到其他Activity),会调起其他的app! 最初的想法是,使用了overridependingtransition,导致在切换过程中,App失去了对touch实践的捕获,结果去掉之后还是无法解决. 也没有什么特别好的想法,这种没有日志的bug最难解决!不停的重试,无意中发现,在Activity切换过程中,使用退出动画(缩放)的Activity 后面都是透明的,launcher都显示了出来,虽然面积不大,但还是被我发现了.

css 设置元素背景为透明

要设置某一元素的背景为透明,在 chrome .firefox.opera 下是这样的: [css] view plain copy background-color: rgba(0, 0, 0, 0.4); rgba 中的最后一个参数 0.4 就是想要的透明度,范围在0-1之间. 在 ie 中一般是这样的: [css] view plain copy background-color: rgb(0, 0, 0); filter: alpha(opacity=40); opacity 表示透明度

Android 设置按钮背景透明与半透明_图片背景透明

Button或者ImageButton的背景设为透明或者半透明 半透明<Button android:background="#e0000000" ... />  透明<Button android:background="#00000000" ... /> 颜 色和不透明度 (alpha) 值以十六进制表示法表示.任何一种颜色的值范围都是 0 到 255(00 到 ff).对于 alpha,00 表示完全透明,ff 表示完全不透明.表达式顺

Android设置Activity启动和退出时的动画

业务开发时遇到的一个小特技,要求实现Activity启动时自下向上弹出,退出时自上向下退出. 此处不关注启动和退出时其他Activity的动画效果,实现方法有两种: 1.代码方式,通过Activity的overridePendingTransition接口, 即在startActivity时调用overridePendingTransition(R.anim.push_bottom_in, 0) 在finish时调用overridePendingTransition(0, R.anim.push

android 设置桌面背景图片适应屏幕大小

今天做demo,设置桌面每天自动更新背景,但是桌面的背景都是被系统裁剪过的图片,上网百度了一下,有个过时的方法,改进后果然有用了! Bitmap bmp=BitmapFactory.decodeResource (getResources(), bg[DailyBg]); try { // super.setWallpaper(bmp); WallpaperManager instance = WallpaperManager.getInstance(ChangeBgImage.this); /

Android:设置EditText 背景

1.android:background 属性指定控件背景 <EditText android:id="@+id/editText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:inputType="text" android:background="@drawable/editor_selec