15

背景をフェードするダイアログボックスの周りのこの「shadowBox」効果を削除するにはどうすればよいですか?

完全にカスタム ビューのように作成できることはわかっていますが、シンプルに保ちたいとしましょう。textView と 2 つのボタンのみを含むダイアログの xml レイアウトがあり、この 1 つのダイアログのみのフェードを停止したいと考えています。

4

5 に答える 5

45

試す:

dialog.getWindow().clearFlags(LayoutParams.FLAG_DIM_BEHIND);
于 2011-08-21T16:07:35.087 に答える
9

style.xml内部に作成しvalues、次のようなものを配置します。

<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="progress_dialog">
    <item name="android:windowIsFloating">true</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowTitleStyle">@null</item>
    <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
    <item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
    <item name="android:backgroundDimEnabled">false</item>
    <item name="android:background">#00ffffff</item> 
</style>

最後に、このスタイルをダイアログ ボックスに配置します。

于 2011-01-21T10:25:04.513 に答える
2

ここでサンプルクラスを与える

public void showDialog () {

    Dialog dialog = new Dialog(this);
    Window window = dialog.getWindow();
    window.setBackgroundDrawableResource(android.R.color.transparent);
    window.requestFeature(window.FEATURE_NO_TITLE);

    dialog.setContentView(R.layout.sample);
    ImageView imggameover, imgplayagain;
    imggameover = (ImageView) dialog.findViewById(R.id.gameover);
    imgplayagain = (ImageView) dialog.findViewById(R.id.playagain);
    imgplayagain.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            // TODO Auto-generated method stub
            startActivity(new Intent(getApplicationContext(), random.class));
            onStop();
            finish();
        }
    });
    dialog.show();
}

ダイアログのレイアウト

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/gameoverlayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@android:color/transparent"
    >
    <ImageView
        android:id="@+id/gameover"
        android:layout_width="225dip"
        android:layout_height="160dip"
        android:background="@drawable/gameover"
        ></ImageView>
    <ImageView
        android:id="@+id/playagain"
        android:layout_width="160dip"
        android:layout_height="wrap_content"
        android:layout_marginLeft="100dip"
        android:layout_marginTop="100dip"
        android:background="@drawable/playagain"
        ></ImageView>
</RelativeLayout>
于 2011-01-21T10:44:38.257 に答える