-1

In my android app, I would like to have a 3-inch sized title text ( requirement from our designer).

I have actionbar tabs under the title bar.

I tried to make the text big using the below code but it gets clipped off. So, I am not able to make it taller. any help will be appreciated

 void setCustomActionBar() {
    ActionBar mActionBar = getActionBar();
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);

    mActionBar.setDisplayShowHomeEnabled(false);
    mActionBar.setDisplayShowTitleEnabled(true);
    LayoutInflater mInflater = LayoutInflater.from(this);

    View mCustomView = mInflater.inflate(R.layout.actionbar_customview,
            null);
    // actionbarTitle
    TextView mTitleTextView = (TextView) mCustomView
            .findViewById(R.id.actionbarTitle);

    // lp.setMargins(0, 10, 0, 10);
    mTitleTextView.setText("Applause Insights");
    mTitleTextView.setTextSize(32);
    mTitleTextView.setGravity(Gravity.CENTER_HORIZONTAL);
    mActionBar.setCustomView(mCustomView);
    mTitleTextView.setLayoutParams(lp);
    mActionBar.setDisplayShowCustomEnabled(true);
}
techtinkerer
  • 1,280
  • 2
  • 15
  • 26
  • Android 5.0 introduces a new Toolbar widget. This is a generalization of the ActionBar pattern but gives you much more control and flexibility in using it. So use Toolbar if is it possible. But if you want use "old" Actiobar check this answer: http://stackoverflow.com/a/12899367/3080479 – Petr Duchek Dec 05 '14 at 19:07
  • 1
    I am using 4.0 so I dont think I can use the 5.0 control - even if there is some compat version, its going to be some good chunk of rewrite I think :-( – techtinkerer Dec 05 '14 at 19:33
  • That solution didn't work. Let me try the style solution. As I said, the title text for me, needs to be actually like 4,5 centimeters. Please do not mark the question as -1 without knowing if some random answer worked for this problem or not. – techtinkerer Dec 06 '14 at 09:45

1 Answers1

1

Try using android:height like the following:

<style name="AppActionBar">
    <item name="android:height">50dp</item>
</style>

<style name="MainActivityStyle" parent="@android:style/Theme.Holo">
    <item name="android:actionBarStyle">@style/AppActionBar</item>
</style>

For more information check this link,

How to change action bar size

Community
  • 1
  • 1
stacktry
  • 324
  • 3
  • 24