How to have activity in Android with a close button at the top corner?

后端 未结 4 1324
长发绾君心
长发绾君心 2020-12-08 23:43

I would like to have an activity which would consist of a close button i.e \'x\' at the right top corner closing the activity. Any examples on this will be very much helpful

4条回答
  •  无人及你
    2020-12-09 00:16

    Maybe an "Up" button is what you really need instead of a close button. From the official Android documentation: "Your app should make it easy for users to find their way back to the app's main screen. One simple way to do this is to provide an Up button on the app bar for all activities except the main one. "

    Details are described here: https://developer.android.com/training/appbar/up-action.html

提交回复
热议问题