I am trying to customize my Android Up Navigation Button by using the text of the action performed. For example I want to put in Cancel in place of the up navigation button in order to show to the users that they can perform cancel operation and go back to the parent activity. How do I achieve this? I know that we can change the logo with the help of a drawable resource but I am looking to put a text in place of the Button. Kindly help
-
I'm not sure if it can be done, but I'd advise against it. See _Don't use labeled back buttons on action bars_ in http://developer.android.com/design/patterns/pure-android.html – matiash May 25 '14 at 19:08
-
Thanks for pointing out that it goes against the guidelines. But I am creating an Android version of an iOS app and I want my android app to be just like the iOS version. Do you think it is possible? Is there no way to tweak around this? – Viswanth May 25 '14 at 19:13
-
1For the sake of Android users across the world. Please don't, give the Android app its own personality, we don't need iOS-alike apps anymore. – user54028 May 25 '14 at 19:18
-
user54028, i have my own requirements. Kindly help if possible or just leave the post as it is. – Viswanth May 25 '14 at 23:47
2 Answers
I understand you wanting to create a seamless experience between different platforms on your applications, but each platform has it's own tools to accomplish goals.
It sounds like you may want to impliment the Done/Cancel bar illustrated in this Google Plus post by Roman Nurik: Android Done Bar
I've used this many times in my applications and had great success with it. Here is a link to the source code: Source

- 118
- 6
-
This is a great alternative to what I am looking for. Il try to incorporate this into my development. – Viswanth May 25 '14 at 23:47
With the solution provided here you can (in a somewhat hacky way) access the ImageView
that displays the up button.
int upId = Resources.getSystem().getIdentifier("up", "id", "android");
if (upId > 0) {
ImageView up = (ImageView) findViewById(upId);
...
}
So you could create a Drawable on the fly and place the text you want (using Canvas, see for example: android - adding a String over a Drawable image?) and finally provide that image to the ImageView
.
As others have said, though, this is specifically pointed out as a bad idea in the Pure Android guidelines...