任何人都可以告訴我如何在android中心對齊標籤文本?我給了android:gravity="center"
LinearLayout
和TabWidget
。它仍然沒有工作。任何人都可以告訴我如何做到這一點?如何在中心對齊標籤文本android
感謝
任何人都可以告訴我如何在android中心對齊標籤文本?我給了android:gravity="center"
LinearLayout
和TabWidget
。它仍然沒有工作。任何人都可以告訴我如何做到這一點?如何在中心對齊標籤文本android
感謝
使用android:layout_gravity="center"
使用本
int tabCount = tabHost.getTabWidget().getTabCount();
for (int i = 0; i < tabCount; i++) {
final View view = tabHost.getTabWidget().getChildTabViewAt(i);
if (view != null) {
// reduce height of the tab
view.getLayoutParams().height *= 0.66;
// get title text view
final View textView = view.findViewById(android.R.id.title);
if (textView instanceof TextView) {
// just in case check the type
// center text
((TextView) textView).setGravity(Gravity.CENTER);
// wrap text
((TextView) textView).setSingleLine(false);
// explicitly set layout parameters
textView.getLayoutParams().height = ViewGroup.LayoutParams.FILL_PARENT;
textView.getLayoutParams().width = ViewGroup.LayoutParams.WRAP_CONTENT;
}
}
}
tabHost似乎不再工作,目前的解決方案是什麼? – 2014-08-20 17:57:01
添加這裏你tried.full代碼。 – Sajmon 2012-07-13 14:49:09
這裏這個鏈接http://joshclemm.com/blog/?p=136引用自定義選項卡視圖的教程。在此選項卡中,選項卡文本位於中央。 – Aerrow 2012-07-13 14:57:53