我有一个xml文件布局,在service里面通过
mView = View.inflate( this, R.layout.match, null );
mWindowManager = ( WindowManager ) getSystemService( "window" );
获得view,然后用
mWindowManager.addView( mView, p );添加view,可是为什么add显示出来的背景不能为透明的呢?
ps:设置过#00000000无效。
无奈求助。。。。
其中p设置如下:
LayoutParams p = new LayoutParams( LayoutParams.TYPE_APPLICATION_PANEL );
p.flags = LayoutParams.FLAG_HARDWARE_ACCELERATED | LayoutParams.FLAG_NOT_FOCUSABLE;
p.token = windowToken;
p.x = x;
p.y = y;
p.width = w;
p.height = h;
p.gravity = 8388659;
布局文件如下:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/intro_bg"
>
<ImageView
android:layout_marginTop="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="center"
android:src="@drawable/unlock_tips" />
<TextView
android:id="@+id/unlock_tv"
android:layout_width="fill_parent"
android:layout_height="25dp"
android:layout_marginBottom="10dp"
android:textSize="17dp"
android:text=""
android:gravity="center"
android:textColor="#ffffff"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
------解决方案--------------------
LZ你是想打开一个不会覆盖当前窗口的弹出框样式的东东?
------解决方案--------------------
你设置下p.alpha的值试试,比如p.alpha = 0.5f。
------解决方案--------------------
你的xml:android:background="@drawable/intro_bg" 不是已经设置背景图片了吗
------解决方案--------------------
2楼层主说的应该没问题的。。楼主你试试imageview弄到mainactivity.java再创建,不要在布局文件里边创建
------解决方案--------------------
你的xml:android:background="@drawable/intro_bg" 不是已经设置背景图片了吗
这个是为了盖住黑色背景暂时放上去的
这就是你了,你设置了背景图片,在下面加入一条android:background="#00000000";试试
------解决方案--------------------
自定义style试试
------解决方案--------------------
这个应该是WindowManager 这个背景不是透明的吧。
我记的POpWindow中加布局文件的背景也不是透明的。好像得设置POpWindow本身的背景为透明才可以。WindowManager 应该也是和POpWindow类似自己默认有背景色
吧