透明活动,带有淡淡的灰色

Lak*_*nan 1 xml android transparent android-activity

我试图在另一个活动上创建一个透明的活动,带有淡淡的灰色色调.我可以调用透明活动,但我无法获得Greyish Tint.请帮我.以下是我的代码.

    <style name="Theme.Transparent">
    <item name="android:windowBackground">@drawable/transparent_background</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowIsFloating">true</item>
    <item name="android:backgroundDimEnabled">false</item>
</style>
<drawable name="transparent_background">#FFFECA11</drawable>
Run Code Online (Sandbox Code Playgroud)

无论我为drawable提供什么颜色值,它都不会被反映为背景.清单中的定义

    <activity
        android:name=".DisplayHelpActivity"
        android:label="@string/title_activity_display_help" 
        android:theme="@style/Theme.Transparent">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.INFO" />
        </intent-filter>
    </activity>
Run Code Online (Sandbox Code Playgroud)

能告诉我你的遗失吗?PS请忘记颜色值.它只是随机我曾经测试它是否有效.

我也使用了以下内容

    <item name="android:windowBackground">@color/transparent</item>
Run Code Online (Sandbox Code Playgroud)

而不是drawable,并在我的color.xml中

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
       <color name="transparent">#80ffeeca</color>
    </resources>
Run Code Online (Sandbox Code Playgroud)

它仍然没有效果.请帮我.

Bal*_*des 6

我认为将活动放在彼此之上并不是一个好主意.如果你想在正常活动之上展示一些东西,那么使用a FrameLayout是一个可行的解决方案:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/main_layout" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#ffffffff"
        android:id="@+id/underlying_layout" >

        <!--Put the parts of your normal activity here -->

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#88666666"
        android:id="@+id/top_layout">

        <!--Put the parts of the layout here, 
        what should be on top of your activity-->

    </LinearLayout>
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)

现在,如果你想让顶层的东西出现或消失,那么你可以setVisibility()像这样使用Views 函数:

View topLevelLayout = findViewById(R.id.top_layout);

//make it disappear with all its sub-Views
topLevelLayout.setVisibility(View.INVISIBLE);

//make it appear with all its sub-Views
topLevelLayout.setVisibility(View.VISIBLE);
Run Code Online (Sandbox Code Playgroud)

UPDATE

在此输入图像描述