-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);
}
的是Android 5.0引入了一個新的工具欄插件。這是ActionBar模式的一個泛化,但給你更多的控制和使用它的靈活性。所以如果可能的話,使用工具欄。但如果你想使用「舊」Actiobar檢查這個答案:http://stackoverflow.com/a/12899367/3080479 – 2014-12-05 19:07:56
我使用4.0,所以我不認爲我可以使用5.0控制 - 即使有一些compat版本,它會成爲一個很好的重寫我認爲:-( – techtinkerer 2014-12-05 19:33:28
該解決方案沒有工作,讓我試試風格的解決方案。正如我所說,我的標題文本,實際上應該是四點五釐米。不要將問題標記爲-1,不知道某些隨機答案是否適用於此問題。 – techtinkerer 2014-12-06 09:45:08