11

How to increase the size of the title bar attached to the top of any screen in android

Mullins
  • 2,304
  • 1
  • 19
  • 18
Sando
  • 1,893
  • 11
  • 29
  • 45

2 Answers2

28

EDIT:

this solution was for API < 11 ... now we have ActionBars

EDIT: first i answer this

Create custom titlebar in Android

EDIT: I'm adding this because I think Sujit gave the wrong answer.

To increase the size of the title bar you will need to add file with this content to res/values

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="CustomTheme" parent="android:Theme">
        <item name="android:windowTitleSize">50dip</item>
    </style>
</resources>

in AndroidManifest.xml file

        <activity android:theme="@style/CustomTheme" android:name=".Activity" android:label="AppName">
...
        </activity>
Community
  • 1
  • 1
Selvin
  • 6,598
  • 3
  • 37
  • 43
  • Have you gone through the link that you have mention here?? If yes then this is what i have also written that you have to create your custom title bar. First try to read whatever are copying and pasting.... – Sujit Jun 09 '11 at 10:35
  • yes i did ... **you wrote** how to build "custom bar" by dissabling real one and **make a fake one** in Layout ... **this link provide information how to build real custom bar in "android way"** – Selvin Jun 09 '11 at 10:46
  • yes but the only difference is that it has requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); instead of getWindow().requestFeature(Window.FEATURE_NO_TITLE) – Sujit Jun 09 '11 at 10:49
  • no ... this is not only difference ... it's about reusing the code like here http://selvinlistsyncsample.codeplex.com/SourceControl/changeset/view/824065689cc2#src%2fselvin%2fListSyncSample%2fCustomWindow.java i build CustomWindow and few of my activities are using this class as a base ... so in this activities i have the same title bar without adding it to layout ... i asume that you don't know what are design patterns and you build all your code adhoc ... it's leading to buggy, not reusable code – Selvin Jun 09 '11 at 10:54
  • 1
    @Selvin Ok what so special about your this CustomWindow, what if I create a base Activity using Sujit procedure and extend all activities of my app with that base activity is not that code reusability, then I must say you should write a book on design pattern, its easy to critic on one rather than admiring – ingsaurabh Jun 10 '11 at 09:34
  • hehe good one first you vote -1 for comments not for answer(which is correct) ... second with Suijit code in base Activity ... well you will have Activity without TitleBar ... nothing more ... you still need to add "title bar" in every layout ... i know that thinking sometimes hurt ... but come on :) – Selvin Jun 10 '11 at 10:21
  • ROFL man your answer is correct and Sujit's is also correct but the way you criticize is wrong also there are many ways to do the same thing, its just matter of choice, and as U said thinking hurts I suggest you to implement and try my way and then tell whether you see the title in all activities or not, Its not better to always think rather trying things helps alot in understanding them – ingsaurabh Jun 10 '11 at 10:57
  • 1
    "This is android title bar and you can not increase its size." <= yeah sure this is correct answer :) – Selvin Jun 10 '11 at 10:58
  • Ok, whats the diff between in built API and overriding :P – ingsaurabh Jun 10 '11 at 11:25
  • 8
    Eh... this answer is the RIGHT one. The one before this was kinda useless to me... Upgrade this one please folks. It's actually helpful. – Henley Jul 17 '11 at 05:52
  • Funny.. I encountered the same problem almost a year later, and read the above answer and kept scratching my head. Came to this one and again, got the job done. This answer is the best. – Henley Apr 15 '12 at 15:10
1

This is android title bar and you can not increase its size. It you need this feature in your application then you can create a custom title bar.

Remove the this default Title bar by using this code in your activity..

getWindow().requestFeature(Window.FEATURE_NO_TITLE);

or this in your manifast inside your activity tag.

android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 

and then create a custom title bar in your XML file.

Sujit
  • 10,512
  • 9
  • 40
  • 45
  • 4
    it's not true ... this answer is wrong ... disabling title bar and making own in activity layout it's not a real solution – Selvin Jun 09 '11 at 10:27
  • @Sujit I guess that Selvin would like had say that the preffered approach is make your own _Title Bar Customized_. Look [here](https://stackoverflow.com/a/27916832/3072683) – aspadacio Dec 07 '17 at 03:05