透明的活动,与灰色的微弱的色调色调、微弱、灰色、透明

2023-09-12 05:43:30 作者:相见不如怀念

我想有一个透明的活动,带着淡淡的灰色色调,在另一个活动。我能够调用透明的活动,但我没能拿到。灰的色调。请帮我。以下是我的code。

I am trying to have a transparent Activity, with a faint grey Color tint, over another activity. I am able to invoke the transparent activity, but I am not able to get the Greyish Tint. Please help me. Following is my code.

    <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>

没有无论什么颜色值I为提拉,它没有被反映为背景。清单中的定义

No matter what colour value I provide for the drawable, it is not being reflected as the background. The definition in manifest

    <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>

可否请您让我知道笏缺失? 附:请忘记颜色值。它只是随机我用来测试它是否正常工作。

Can you please let me know wat is missing? P.S. Please forget the color value. Its just random I used to test if it works.

我用下面还有

    <item name="android:windowBackground">@color/transparent</item>

而不是绘制,并在我的color.xml

instead of the drawable, and in my color.xml

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
       <color name="transparent">#80ffeeca</color>
    </resources>

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

it still has no effect. Please help me.

推荐答案

我不认为这是一个好主意,把活动对彼此顶部。如果你想展示的东西在你的正常活动的顶部,然后用FrameLayout是更多钞票的解决方案:

I don't think it's a good idea to put activities on top of each other. If you want to show something on top of your normal activity, then using a FrameLayout is a posible solution:

<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>

现在,如果你想使顶层的东西出现或消失,那么你可以使用该浏览setVisibility()像这样的功能:

Now if you want to make the top level stuff appear or disappear, then you can use the Views setVisibility() function like this:

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);

更新

UPDATE