Reputation: 3305
How do I remove this "shadowBox" effect around the dialog box that fades the background?
I know I can create like totally custom view but let's say I want to keep it simple. I have xml layout for dialog with only textView and 2 buttons and I want to stop the fade only for this one dialog.
Upvotes: 15
Views: 19663
Reputation: 70
Just that you know it is also possible to change the dim amount by writing this in your theme:
<item name="android:backgroundDimAmount">0.5</item>
Upvotes: 0
Reputation: 35946
here give the sample class
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();
}
Dialog's layout
<?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>
Upvotes: 2
Reputation: 153
Simply use
dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
Upvotes: 6
Reputation: 11251
create style.xml
inside values
and put things like this:
<?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>
And in the end, put this style to your dialog box.
Upvotes: 9