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>
sabadow
  • 5,095
  • 3
  • 34
  • 51
jquery404
  • 653
  • 1
  • 12
  • 26

2 Answers2

1

You may need to take a look at Crouton library:

enter image description here enter image description here

Eng.Fouad
  • 115,165
  • 71
  • 313
  • 417
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.

Community
  • 1
  • 1
CSmith
  • 13,318
  • 3
  • 39
  • 42
  • actually I want it like a overlay to another activity. like a custom dialog or smoothing as shown in the picture. – jquery404 Nov 06 '13 at 13:13
  • edited answer, I get what your asking now. You need to know how to do a custom dialog, then also your layout needed tweaking – CSmith Nov 06 '13 at 13:22