0

I am trying to make a alert dialog which will show like the picture. Im trying to use frame layout but can't make the it right like the picture. In my current layout I used an imageView and textview. enter image description here

<LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <FrameLayout android:layout_width="fill_parent" android:layout_height="fill_parent"> <ImageView android:layout_width="fill_parent" android:layout_height="wrap_content" android:src=""/> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@strings/text" /> </FrameLayout> <!---<other layouts---> </LinearLayout> 
4
  • Which layout in your code represent a error? Commented Nov 6, 2013 at 13:08
  • @Demand im trying to make it as overlay to another activity. like a custom dialog or smoothing like the picture. Commented Nov 6, 2013 at 13:11
  • 1
    you can use a Toast with a custom layout.. Commented Nov 6, 2013 at 13:17
  • @bakriOnFire you helped me a lot. Toast with custom layout did the trick :) Commented Nov 6, 2013 at 17:33

2 Answers 2

1

You may need to take a look at Crouton library:

enter image description here enter image description here

Sign up to request clarification or add additional context in comments.

Comments

0

To display a Dialog with a custom content,

ViewGroup myRootViewGroup = /* root ViewGroup of your activity or fragment */; mContext = /* your activity context */; AlertDialog.Builder builder = new AlertDialog.Builder (mContext, AlertDialog.THEME_HOLO_DARK); LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.mylayout, (ViewGroup) myRootViewGroup); builder.setView(layout); Dialog dialog = builder.create(); dialog.show(); . . . dialog.dismiss(); 

great answer at Creating a custom dialog in Android on this also.

You might also consider that the layout your looking for is basically the standard AlertDialog layout (with no buttons), you can just do builder.setIcon() and builder.setTitle().

For your layout, change LinearLayout orientation="horizontal", remove the FrameLayout altogether, set ImageView layout_width="wrap_content". This:

<LinearLayout android:id="@id/mylayout" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src=""/> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@strings/text" /> </LinearLayout> 

You'll also likely want to fiddle with padding on the Image/Text Views to get the exact look.

2 Comments

actually I want it like a overlay to another activity. like a custom dialog or smoothing as shown in the picture.
edited answer, I get what your asking now. You need to know how to do a custom dialog, then also your layout needed tweaking

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.