任何人都可以告诉我如何在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