1

別のアクティビティの上に、かすかな灰色の色合いの透明なアクティビティを作成しようとしています。透明なアクティビティを呼び出すことはできますが、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>

ドローアブルにどのような色の値を指定しても、背景として反映されません。マニフェストの定義

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

ワットが欠落していることを教えてください。PS 色の値を忘れてください。それが機能するかどうかをテストするために使用したのはランダムです。

私は以下も使用しました

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

drawable の代わりに、私の color.xml に

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

それはまだ効果がありません。私を助けてください。

4

2 に答える 2

6

活動を重ねるのは良い考えではないと思います。通常のアクティビティの上に何かを表示したい場合FrameLayoutは、 a を使用することが考えられる解決策です。

<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()ように 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);

アップデート

ここに画像の説明を入力

于 2012-09-01T19:42:26.897 に答える
3

問題は色自体の値にあると思います。

#FFFECA11

その理由は、色が 4 つの値 #AARRGGBB に分解されるためです。最初の 2 つは透明な値で、最初の 2 つの値にFFを使用することで、透明でないことを保証します。次の値を使用して、約 50% の透明度を取得してみてください。

#7FFECA11

詳細については、次のリンクを参照してください: http://developer.android.com/guide/topics/resources/more-resources.html#Color

于 2012-09-01T19:27:20.480 に答える