0

I am building a Custom dialog box using the Android Developer docs link , for this i made a layout file

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rotatelayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#80000000"
>

<ImageView 
    android:id="@+id/dialogimage"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    />
</LinearLayout>

and i am inflating this dialog,

AlertDialog dialog;
AlertDialog.Builder builder;
builder = new AlertDialog.Builder(TabsActivity.this);
LayoutInflater inflator = (LayoutInflater)   getSystemService(LAYOUT_INFLATER_SERVICE);
View view = inflator.inflate(R.layout.rotate_dialog_layout, (ViewGroup) findViewById(R.id.rotatelayout));   
ImageView image = (ImageView) view.findViewById(R.id.dialogimage);
image.setOnClickListener(new RotateLockListener());
image.setBackgroundColor(Color.parseColor("#80000000"));
if(locked) 
{
    image.setImageResource(R.drawable.lock_icon);
}
else 
{
    image.setImageResource(R.drawable.unlock_icon);
}
builder.setView(view).setCancelable(true);
dialog = builder.create();
dialog.setView(view, 0, 0, 0, 0);
timerDelayRemoveDialog(time, dialog);
dialog.show();

but still it appears as how dialog appears

I have tried all the help provided at the stack over flow

Setting ImageView background to transparent,

Setting transparency by #80000000 and

Setting Dialog window transparency

But none of them worked, it still showing up.

Community
  • 1
  • 1
jeevs
  • 261
  • 6
  • 20

2 Answers2

2

Or you can use Dialog class for this,

Dialog dialog = new Dialog(this,
                android.R.style.Theme_Translucent_NoTitleBar);
        Window window = dialog.getWindow();
        window.setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
                WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        window.setLayout(ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.FILL_PARENT);
        dialog.setCancelable(true);

        dialog.setCanceledOnTouchOutside(true);
        dialog.setContentView(R.layout.temp);
        dialog.show();
Andro Selva
  • 53,910
  • 52
  • 193
  • 240
  • can you tell me what exactly in that code is producing that black background in the figure? – jeevs Jul 23 '12 at 08:02
  • 1
    That's the default theme for any "Alert" Dialog. I don't know how to remove the Theme from Alert Dialog, but this is what I use for Custom Dialog and it works fine. – Andro Selva Jul 23 '12 at 08:16
1

Try using this as the style of your View :

<style name="Dialog_Fullscreen">
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowNoTitle">true</item>
</style> 
Slickelito
  • 1,786
  • 20
  • 28