Android: change the position of the alert dialog icon

I have a warning dialog box in the android xml file.my warning dialog box with an icon on the left. I want to reposition the icon on the right. I do not want to use custum dialog too

like this:

enter image description here

+7
android user-interface android-ui
source share
2 answers

a) If you use it as drawn in the dialog header (TextView), just use drawableRight

android:drawableRight="@drawable/yourIcon" 

b) If it is ImageView / ImageButton in RelativeLayout, use alignParentRight

 android:layout_alignParentRight="true" 

c) If it is ImageView / ImageButton in LinearLayout, put it after TextView

 <LinearLayout android:layout_width="300dp" android:layout_height="300dp"> <TextView android:text="some text" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <ImageView android:src="@drawable/yourIcon" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout> 

Hope this helps you.

0
source share

You can use the OnShowListener method to set the direction of the warning dialog box in RTL. after installing the name, message, .... use this method.

  dialog = alertdialogbuilder.create(); dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dlg) { dialog.getWindow().getDecorView().setLayoutDirection(View.LAYOUT_DIRECTION_RTL); // set title and message direction to RTL } }); dialog.show(); 
0
source share

All Articles