活动应该是透明的,但黑色的背景 [英] Activity should be transparent, but has black background

查看:196
本文介绍了活动应该是透明的,但黑色的背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的用例是写了一个景观摄像头preVIEW覆盖控制器活动。我接着写一个透明的主题,从一对夫妇的教程进行操作。

My use case is writing an overlay controller activity for a landscape camera preview. I followed the instructions from a couple of tutorials for writing a transparent theme.

所以,我的RES /价值/ style.xml看起来是这样的:

So my res/values/style.xml looks like this:

<resources>

  <style name="Theme" parent="android:Theme" />

  <style name="Theme.Transparent">
      <item name="android:windowBackground">@drawable/transparent_background</item>
  </style>

  <drawable name="transparent_background">#00000000</drawable>

</resources>

活动片段:

    <activity android:name=".CameraPreview"
       android:label="Camera"
       android:screenOrientation="landscape"
       android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity android:name=".Controlls"
              android:label="Controlls"
              android:screenOrientation="portrait"
              android:theme="@android:style/Theme.Translucent">
    </activity>

当我开始这项活动从我的根系活力,布局得到正确绘制,而背景保持黑色。我试图用 @android:款式/ Theme.Translucent 代替,但这个主题继承调用活动的方向(横向),并且那不是我想要的。

When I start this activity from my root activity, the layout gets drawn correctly, but the background stays black. I tried to use @android:style/Theme.Translucent instead, but this Theme inherits the orientation from the calling activity (landscape) and thats not what I want.

编辑:

应用程序举着相机preVIEW设置为横向视图,因为它不正确地在纵向显示preVIEW。 (见老谷歌的错误报告

The application holding the camera preview is set to landscape view as it does not display the preview correctly in portrait orientation. (see old google bug report)

我想要做的是把用户交互界面的独立活动在镜头表面支架前(此活动应被设置为肖像,甚至更好的'传感器')

What I wanted to do was to put an independent activity for user interaction interface in front of the camera surface holder (this activity should be set to 'portrait', or even better to 'sensor')

推荐答案

尝试内置 @android:款式/ Theme.Translucent ,而不是你自定义的,根据到<一个href="http://zaman91.word$p$pss.com/2010/03/22/android-how-to-create-transparent-or-opeque-background/"相对=nofollow>这个博客帖子。我还没有尝试这样做我自己,所以我不知道是否该技术写有工程或没有。

Try the built-in @android:style/Theme.Translucent instead of your custom one, according to this blog post. I haven't tried to do this myself, so I don't know if the technique written about there works or not.

这篇关于活动应该是透明的,但黑色的背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆