本例介绍使用透明背景绘制OpenGL 图形。步骤如下:
1. 对于Activity使用透明主题
<activity android:name=”.graphics.TranslucentGLSurfaceViewActivity”
android:label=”Graphics/OpenGL ES/Translucent GLSurfaceView”
android:theme=”@style/Theme.Translucent”
android:configChanges=”keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize”>
<intent-filter>
< action android:name=”android.intent.action.MAIN” />
<category android:name=”android.intent.category.SAMPLE_CODE” />
< /intent-filter>
< /activity>
2. 使用8888 (RGBA) 格式,Alpha通道是显示透明图形必需的。
// We want an 8888 pixel format because that's required for
// a translucent window.
// And we want a depth buffer.
mGLSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
3. 为GLSurfaceView指定Alpha通道
mGLSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
4. 为绘制的图行背景为颜色(0,0,0,0)
gl.glClearColor(0,0,0,0);

分享到:
相关推荐
#### 2.37 App->Search->QuerySearchResults 进一步讲解了如何处理搜索查询结果。 #### 2.38 App->Service->ForegroundServiceController 这部分内容介绍了如何创建前台服务。 #### 2.39 App->Service->...
##### (37) App->Search->QuerySearchResults - **目的**:学习如何处理搜索查询的结果。 - **主要内容**: - 分析搜索关键词并获取搜索结果。 - 显示搜索结果列表。 ##### (38) App->Service->...
##### (16) App -> Activity -> Translucent - **概述**:讨论了如何创建半透明 Activity。 - **技术点**: - **窗口属性**:通过修改窗口属性实现半透明效果。 ##### (17) App -> Activity -> TranslucentBlur - ...
在Android上删除Modal的StatusBar背景 之前 后 用法 npm install react-native-modal-translucent --save # or yarn add react-native-modal-translucent 如果您的RN版本低于0.60,则需要手动链接。 react-native ...
-- //loads page specific $this->stencil->js($args) from Controller (see docs) --> </head> <!-- $body_class will always be the class name --> <body class="<?...
[Android 毕业设计-课程设计] 美图与开发资讯 App -看妹纸与开发资讯.zip # 一个看妹纸与开发资讯的Android APP,具有自动缓存、清理缓存、分享、搜索与添加收藏的功能,使用Android Architecture Components构建的...
-- 在这里添加对话框的内容 --> </LinearLayout> ``` 2. **创建Dialog实例**:在Java代码中,使用`Dialog`类或`AlertDialog.Builder`来创建对话框实例。设置对话框的样式,包括宽度、高度和主题。为了实现半透明...
在Android应用开发中,状态栏...-- 在AndroidManifest.xml中 --> ... android:theme="@style/Theme.AppCompat.NoActionBar" <!-- 使用无Action Bar的主题 --> </application> <!-- 在res/values/styles.xml中 --> ...
- 当父 Activity 启动子 Activity 且子 Activity 退出时,父 Activity 的生命周期调用顺序为:`onPause()` -> `onStop()` -> `onRestart()` -> `onStart()` -> `onResume()`。 - 用户按下 Home 键,Activity 调用...
Android 4.4 (KitKat) introduced translucent system UI styling for status bar, then Android 5.0 offers simple ways to enable translucency in Activity( android:windowTranslucentStatus) and tint color ...
对于KitKat(API 19)和Lollipop之间的版本,可能需要使用第三方库如`android-translucent-status-bar`或者自定义ViewGroup来实现类似效果。对于更早的版本,透明状态栏功能可能受限,需要考虑其他设计策略。 5. **...
-- 其他属性 --> <item name="android:windowTranslucentStatus">true</item> </style> ``` 确保你的应用最低支持API 19(KitKat)以上,因为这个特性是在Android 4.4引入的。 2. **处理高度问题**:状态栏透明后...
-- 设置状态栏颜色 --> <item name="colorPrimaryDark">@color/colorStatusBar</item> </style> ``` 在这里,`colorPrimaryDark`属性用于设置状态栏颜色,`@color/colorStatusBar`应该替换为你想要的颜色资源。...
-- 其他属性 --> <item name="android:windowTranslucentStatus">true</item> <item name="android:windowTranslucentNavigation">true</item> </style> ``` 2. **自定义颜色**: 如果希望状态栏和导航栏的...
-- 先设置为透明,以便覆盖 --> <item name="android:windowDrawsSystemBarBackgrounds">true</item> <item name="android:statusBarColor">@color/colorPrimaryDark</item> <!-- 或者直接在这里设置颜色 --> ...
-- Your views here --> </LinearLayout> ``` 3. **启动透明Activity** 当你需要启动透明Activity时,可以通过Intent进行操作。在源代码中,你可以这样写: ```java Intent intent = new Intent(this, ...
默认情况下,Android会重新创建Activity实例以适应新的屏幕方向,因此会经历`onDestroy()` -> `onCreate()`流程。如果你想在横竖屏切换时不重建Activity,可以在AndroidManifest.xml中对应的Activity标签内添加`...
-- API 21+ --> <item name="android:statusBarColor">@android:color/transparent</item> </style> ``` 2. **在BaseActivity中应用主题**: 在`AndroidManifest.xml`中,将新创建的主题应用于BaseActivity或整个...
-- 设置窗口为半透明 --> <item name="android:windowAnimationStyle">@android:style/Animation.Translucent</item> <!-- 使用半透明动画 --> </style> ``` 最后,在`AndroidManifest.xml`中将这个自定义风格应用...
1. **使用Theme**: 设置Activity的主题为全透明,例如在AndroidManifest.xml中添加`android:theme="@android:style/Theme.Translucent.NoTitleBar"`,这样Activity在加载时就不会有默认背景颜色。 2. **延迟启动...