How to get that cross button/image (red circled) on Custom dialog box's boundary?
Android is not Windows. You don't need a Windows style 'Close' button. Also, Android is not MacOS, so you don't need a little shiny red candy-like dot either.
When you develop an app for a mobile platform you should conform to the User Interface Guidelines that define the usage patterns and visual styles of that platform.
Android does not have title bars, does not have dropdown menus, and does not have minimize/restore/close buttons. Don't try to make them, or you will make an app that looks like it was never meant for the Android Platform.
The "Back" hardkey is the button that does exactly what you want. It closes a dialog without making a selection. Let the Android platform do the same thing here. Don't force your users to think in another OS than the one they use.
HI,
you have to follow these steps to make this Custom dialog box.
create a xml file style.xml in your values folder. and enter style in your resource tag.
<style name="Theme.CustomDialog"
parent="android:style/Theme.Dialog">
<item name="android:windowBackground">@drawable/bg_popup</item>
<item name="android:windowNoTitle">true</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
</style>
create a custom_dialog.xml in layout folder.
<RelativeLayout android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_marginTop="10dp" android:layout_marginRight="10dp">
</LinearLayout>
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:background="@drawable/red_cross"
android:layout_alignParentRight="true" android:layout_alignParentTop="true">
</ImageView>
</RelativeLayout>
finally access this layout in an activity it will work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With