0

I am trying to do in my app that i will have a clickable text in the middle of the actionbar like the whatsapp app have , In this picture you will see in the actionbar it got details of the person and its clickable , that is the exactly thing i am looking for

enter image description here

I saw that i can add subtitles and ofcourse the main title of the actionbar but i didnt seem to find a good result for that exact thing Thanks heads up :)

Dhaval Parmar
  • 18,812
  • 8
  • 82
  • 177
user2202255
  • 21
  • 3
  • 5

2 Answers2

0

enter image description here

use this way:

ActionBar action = getSupportActionBar();
        action.setHomeButtonEnabled(true);
        action.setDisplayShowTitleEnabled(true);
        action.setTitle("Title");
        action.setSubtitle("Sub title");
        action.setIcon(getResources().getDrawable(R.drawable.ic_launcher));

for < 11 Android API use actionbarsherlock

or you can also use custom layout for actionbar and actionbar item click.

https://stackoverflow.com/a/7981633/1168654

Community
  • 1
  • 1
Dhaval Parmar
  • 18,812
  • 8
  • 82
  • 177
0

Add TextView as CustomView that will mimic the plain title and at the same time clickable, instead putting it with setTitle(). Add click listener to the TextView before you supply it to the ActionBar. Don't forget to stretch to the size of the ActionBar.

Hope this idea helps.

Edit:

To get the same appearance in terms of size of text of the title and subtitle look at styles.xml

<style name="TextAppearance.Widget.ActionBar.Title"
       parent="@android:style/TextAppearance.Medium">
</style>

<style name="TextAppearance.Widget.ActionBar.Subtitle"
       parent="@android:style/TextAppearance.Small">
</style>



<style name="TextAppearance.Medium">
    <item name="android:textSize">18sp</item>
</style>

<style name="TextAppearance.Small">
    <item name="android:textSize">14sp</item>
    <item name="android:textColor">?textColorSecondary</item>
</style> 
Nikola Despotoski
  • 49,966
  • 15
  • 119
  • 148