2014-12-05 65 views
-2

在我的android應用程序中,我想要一個3英寸大小的標題文本(來自我們設計師的要求)。android中的大動作條標題

我有標題欄下的操作欄選項卡。

我試圖使用下面的代碼使文本大,但它被截斷。所以,我無法做得更高。任何幫助將不勝感激

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); 
} 
+0

的是Android 5.0引入了一個新的工具欄插件。這是ActionBar模式的一個泛化,但給你更多的控制和使用它的靈活性。所以如果可能的話,使用工具欄。但如果你想使用「舊」Actiobar檢查這個答案:http://stackoverflow.com/a/12899367/3080479 – 2014-12-05 19:07:56

+1

我使用4.0,所以我不認爲我可以使用5.0控制 - 即使有一些compat版本,它會成爲一個很好的重寫我認爲:-( – techtinkerer 2014-12-05 19:33:28

+0

該解決方案沒有工作,讓我試試風格的解決方案。正如我所說,我的標題文本,實際上應該是四點五釐米。不要將問題標記爲-1,不知道某些隨機答案是否適用於此問題。 – techtinkerer 2014-12-06 09:45:08

回答

0

嘗試使用android:height類似如下:

<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> 

欲瞭解更多信息,檢查此鏈接,

How to change action bar size