首先插入DLL命令 ,代码如下:
DLL命令 设置透明, 整数型, , "SetLayeredWindowAttributes"
参数 hwnd, 整数型
参数 crkey, 整数型
参数 alpha, 字节型
参数 dwflags, 整数型
DLL命令 取窗口风格, 整数型, , "GetWindowLongA"
参数 hwnd, 整数型
参数 nindex, 整数型
DLL命令 设置窗口, 整数型, , "SetWindowLongA"
参数 hwnd, 整数型
参数 nindex, 整数型
参数 dwnewlong, 整数型
再插入窗口代码:
_启动窗口底色 = #品红
设置窗口 (取窗口句柄 (), -20, 位或 (取窗口风格 (取窗口句柄 (), -20), 524288))
设置透明 (取窗口句柄 (), #品红, 200, 1)
你说的且禁止状态,应该在这设置。
直接设置恐怕不行,我想了一种方法你可以看看行不。首先得到windows桌面窗口的句柄,把桌面窗口内容截图,计算你的opengl窗口位置以及窗口显示区域大小,将截图上相同部分的内容作为背景给opengl窗口,只要窗口移动就重新绘制背景,这样我想应该可以。不过单纯的opengl开发估计难实现,还是要结合VC++,用windows编程才能调用windows的API函数1 在res/values 下建立colorxml
<resources>
<color name="transparent_background">#80ffffff</color>
</resources>
PS: #80是透明度的值(即80%透明),ffffff是颜色值(为黑色)
2 在res/values下建立stylexml
<resources> <style name="Transparent" parent="android:style/ThemeDialog"> <item name="android:windowBackground">@color/transparent_background</item> <item name="android:windowNoTitle">true</item> <item name="android:windowIsTranslucent">true</item> <item name="android:windowAnimationStyle">@+android:style/AnimationTranslucent</item> </style></resources>
PS: parent="android:style/ThemeDialog" 是将activity设置为d出式窗口
3 在AndroidManifestxml中找到要d出的activity,加入theme:
<activity android:name="ActivityName" android:theme="@style/Transparent" />完成上面设置后,你的activity就已经是透明的了,但是该Activity中的控件还没有透明,如果还需要控件透明,则需要在该activity的代码中加入如下代码:
//设置activity中的控件透明 Window window = getWindow(); WindowManagerLayoutParams wl = windowgetAttributes(); wlflags = WindowManagerLayoutParamsFLAG_KEEP_SCREEN_ON; wlalpha=095f;//设置透明度,00为完全透明,10为完全不透明 windowsetAttributes(wl);
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)