I have an activity and I have set as a dialog using
<activity android:name=".ChangeUserImageActivity" android:theme="@android:style/Theme.Dialog"></activity>
How can I create a close button at the top right? Currently, my layout is as follows and I am using absolute layout…
<Button
android:id="@+id/closebtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="260px"
android:layout_y="5px"
android:text="X"
android:textSize="18sp"
android:onClick="close_click"
/>
Modify your current layout so the parent is a
RelativeLayoutand then yourButtonwill look like this:And of course you’ll have to modify your current layout to use the
RelativeLayout(the layout you didn’t added to your question)