0

My question is how to crate a message dialog which is look like given picture

Message dialog

i want to apply this message dialog in bitmap picture

Ashish Dwivedi
  • 8,048
  • 5
  • 58
  • 78

3 Answers3

1

You can do like this.......

Layout msgbox1:-

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content" android:layout_gravity="center_vertical|center_horizontal">
<ImageView android:id="@+id/ImageView01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/image1" android:layout_gravity="center_vertical|center_horizontal"></ImageView>
</LinearLayout>

Layout msgbox2:-

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content" android:layout_gravity="center_vertical|center_horizontal">
<ImageView android:id="@+id/ImageView01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/image1" android:layout_gravity="center_vertical|center_horizontal"></ImageView>
</LinearLayout>

Java code:-

private static final int MsgBox1 = 0,MsgBox2 = 1; //Declaration done on top

.

protected Dialog onCreateDialog(int id) 
{
     dialog = new Dialog(tagame.this,android.R.style.Theme_Light_Panel);
     switch(id) {
        case MsgBox1:
            dialog.setContentView(R.layout.msgbox1);
        break; 
        case MsgBox2:
            dialog.setContentView(R.layout.msgbox2);
        break; 

    }
      return dialog;
}

For displaying the message1 box you can use...

showDialog(MsgBox1);

For hide the message box...

removeDialog(MsgBox1);
0

Set a time interval and change your bitmap dynamically.

Edited Detailed Answer:

You may use like this for the imageView. imageView.postDelayed (Runnable action, long delayMillis)

For utilizing the above method,

U have to create a Runnable which will handle your BitMap value changes. and also implement Thread.sleep(time) in Runnable.

Generally this method places the ImageView after the delayMillis value. So better you have to call this method after initializing immediately the imageView. And make that delayMillis value as ur wish. (In your case, that should be very less).

So that according to that Thread.sleep(time) method your bitmap will be changed dynamically.

My First Suggestion: (Set a time interval and change your bitmap dynamically)

I suggested to set a Timer in the Activity and based on the Timer settings, just provide the BitMap values to your ImageView to change it dynamically.

Hope you understand and feel usefull.

Kartihkraj Duraisamy
  • 3,171
  • 2
  • 25
  • 36
0

You can do this by creating a custom dialog box. Step1.Create a style in String file in res

<style name="myQuitDialog" parent="android:Theme.Dialog"> 
   <item name="android:gravity">center_horizontal</item>

    </style>       

Step2. Create the xml file in layouts

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/layout_quit"
              android:orientation="horizontal"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:background="@drawable/image which u want to show"
 >

</RelativeLayout>

Step3. Write code of custom dialog box in src

class Custom_Dialog extends Dialog {

        protected Custom_Dialog(Context context, int theme) {
            super(context, theme);
            // TODO Auto-generated constructor stub
        }

    }
private void show_alert() {
        final Custom_Dialog alertbox = new Custom_Dialog(this, R.style.myQuitDialog);
        Window window = alertbox.getWindow();
        window.setBackgroundDrawableResource(android.R.color.transparent);
        window.requestFeature(window.FEATURE_NO_TITLE);

        alertbox.show(); 
        alertbox.setCancelable(true);
        alertbox.setCanceledOnTouchOutside(true);


                 alertbox.dismiss();
            }



    }

In this way you can do this.

Naresh Sharma
  • 4,323
  • 7
  • 48
  • 68
  • Thanks you very much. but i had done what you want to say, I want to create a message box which have functionality to increase size of message box color and apply over image view – Ashish Dwivedi Apr 16 '12 at 11:58