android透明背景
㈠ 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 Button 怎么把背景设置透明
Android控件设置边框,或者背景可以使用XML来配置,背景透明只需要设置solid 的值为 #00000000即可,前面两位是透明度,后面6位是RGB颜色值,具体示例代码如下:
1.在drawable新建一个 buttonstyle.xml的文件,内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 连框颜色值 --><item>
<shape>
<solid android:color="#ff0000" />
</shape>
</item>
<!-- 主体背景颜色值 -->
<item android:bottom="3dp" android:right="3dp">
<shape>
<solid android:color="#ffffff" />
<padding android:bottom="10dp"
android:left="10dp"
android:right="10dp"
android:top="10dp" />
</shape>
</item>
</layer-list>
2.然后在布局文件里面引入这个xml,示例代码如下:
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button1"
android:background="@drawable/buttonstyle" />
㈣ android怎么把activity的最底层view的背景设为透明
设置背景为透明
1、设置背景为透明
<ImageView
android:id="@+id/tv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"/>也可以设置颜色值,前两位为透明度
2、设置背景透明度
<ImageView
android:id="@+id/tv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0"/>
相应的也可以在java代码中设置透明
㈤ android设置透明使底部控件可见
在Android上设置透明背景以使底部控件可见,可以使用设备位烂拿图来实现,只需将设备位图的Alpha值设置为零,即可让底部控件可见。除此之渣历凳外,还可以使用setAlpha()方法来设置Alpha值,以便让底部控件显示出来。
在Android上设置透明背景以使底部控件可见,可以使用设备位图来如旅实现,只需将设备位图的Alpha值设置为零,即可让底部控件可见。除此之外,还可以使用setAlpha()方法来设置Alpha值,以便让底部控件显示出来。
㈥ 如何为Android的ImageView和GrilView设置透明背景色
在布局文件中,可以使用属性android:background="#00ffffff",在方法中使用view.setBackgroundColor(android.graphics.Color.parseColor("#00ffffff"));
在GrilView中者孝注意,如果有子视图,物嫌御子视图的背景设为透罩岩明才能使GrilView背景全部透明。
㈦ Android设置Activity背景为透明style的方法
1.设置Theme.Translucent
只需要在Manifest中需要透明的Activity内设置theme为以上任意一个就可以了
2.在Activity的layout.xml文件中,设置父布局背景透明度(不设置背景色默认全透明),不设置透明度看不出效果,如果子控件设置了背景色且不透明,则子控件所占位置无透明效果。
3.效果图
1.使用自定义的Theme
2.在res-values-styles.xml中添加MyTransparent
3.在res-values-colors.xml中添加透明颜色值
4.以上步骤设置完成和方法一有同样的效果,省去了在layout.xml设置透明背景色(如果在布局中页设置了背景色,将以布局中的为准)。方法二相对灵活一点,可以多设置一些属性,如模糊背景:
㈧ 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中模糊透明的popupvwindow背景怎么实现
这里的模糊都是给设余敬置的背景半透明,就是android:background设置为半透明的在color.xml中定义半透明的方式是这样,#AARRGGBB,#后边的AA就是透明度,从00不透明到FF纯透缺毁罩明,后伏闹面的RRGGBB是从000000到FFFFFF的从黑色到白色,根据你的界面应该是半...
㈩ android 如何让一个dialog的背景为透明
北京设置透明?你可以设置dialog的样式,通过Style 来设置;
Android Dialog背景全透明无边框 Theme Style
<style name="Translucent_NoTitle" parent="android:style/Theme.Dialog">
<item name="android:windowNoTitle">true</item>
<item name="android:background">#00000000</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:windowIsTranslucent">true</item>
</style>