I want to achieve the following, as you can see a Dialog
at the top has a circular close(x) icon . I have the Dialog
but I need the mentioned icon, any ideas to get this or something similar?
I have converted a normal LayoutDialog
to , like this. In the manifests I have applied the following Style
style
<style name="formularios" parent="Base.Theme.AppCompat.Light.Dialog">
<item name="android:background">@color/formulario</item>
<item name="android:radius">@dimen/from</item>
</style>
and then in the manifests I apply the style
android:theme="@style/formularios"
What you need is to create a CustomDialog which you are going to make from a
Layout
common one with a transparent background , you can use an image to place your options there, such as the close button. Generally I used frameLayout .Already in your activity you fill your dialog with the
layout
one you have created:I leave you a complete example so that you understand it much better
Dialog Content Layout
That goes like this:
As you can see you can create a dialog from a layout or whatever you want, I use this type of dialog when I require a dialog with many options or one that does not maintain the common aspect.
If you can, it's all a layout issue, I suggest the following:
The blue container would be the parent or the main view of the DialogFragment can be a RelativeLayout.
The red container would be the close button aligned to the right with margins as you need and you put the id "@+id/btn_close".
The green container under the "close" button would layout a second child LinearLayout could be in this case for the options panel use the attribute layout_below="@id/btn_close" for example.
Now you are going to put a transparent background on the parent container, that is to make it look like the "close" button is in the air or floating.
and to the container under the "close" or the LinearLayout place a drawable made by you that has a white background with rounded edges or whatever you need and that's it.
It only remains for you to program what each button does.
this is how I would do it and I have already had to do this type of thing.