0

I want to have a textview that says "Edit" aligned to the right of an action bar but don't know to implement it. Should it be in a menu resource? If so, I want to be able to customize the colour of it. Otherwise, should I put it within the toolbar xml itself?

2 Answers 2

1

You should use a toolbar instead, it's a viewgroup like any other viewgroup, then you can put the TextView inside it, see this question for an example.

Sign up to request clarification or add additional context in comments.

Comments

0

You will have to write a custom implementation of action bar only. You can do something like this if you're not using toolbar.

try { getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); getSupportActionBar().setCustomView(R.layout.custom_toolbar); textView_actionBar = (TextView)findViewById(getResources().getIdentifier("action_bar_textView","id",getPackageName())); textView_actionBar.setText("Your_title"); } catch (NullPointerException e) { e.printStackTrace(); } 

Define the textView's clicklistener as per need.

In custom_toolbar.xml just put an TextView and align it to right end. The layout background set as per your choice.

1 Comment

please accept the answers that provide you the solution to your problem

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.