0

I can setTitle("My Title"), but what I'm looking to do is set two titles... one on the left side and one on the right. How might I do that?

I currently have 2 textviews, aligned parent left and right... the textappearance is changed. But I'm hoping to get that into the titlebar using code so I don't have to use some background to simulate the titlebar.

Roger
  • 4,249
  • 10
  • 42
  • 60

5 Answers5

0

I don't think you can...I think Android only allows one title...but what you could do is

setTitle("My Title left                       My title right");

It's more than a little bit of a hack but it might work.

Full disclosure: haven't tried it.

Chris Thompson
  • 35,167
  • 12
  • 80
  • 109
0

Look at this tutorial for skinning / theming your titlebar

Mark Mooibroek
  • 7,636
  • 3
  • 32
  • 53
0

I'm playing around with some files right now to try and create this dual title bar.
It looks like this post would be helpful: my_own_titlebar_backbutton_like_on_the_iphone.
The comment written on this post at Thu Jan 29, 2009 5:55 pm contains the sample files, title1.zip, a second source file, title2.zip is a few comments below that one as well.

Aliaksandr Belik
  • 12,725
  • 6
  • 64
  • 90
TomHarrigan
  • 618
  • 4
  • 10
0

You can define a custom view layout and tell the system to use it with:

getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.text_title);

You can make your title view a RelativeLayout with two children positioned as you like. This should be done in onCreate() before calling setContentView(). See this thread for more discussion of using a custom view.

Community
  • 1
  • 1
Ted Hopp
  • 232,168
  • 48
  • 399
  • 521
0

If you look at the Bluetooth Chat example on the Android Resources page, here, you'll see that it has exactly that sort of format. Details on how to access it are included there. It contains an XML edit and a few other simple modifications in your initialization code.

Cubic
  • 358
  • 1
  • 3
  • 9