我想只显示没有图片的tabbar项目的标题。可能吗?当我尝试设置
时private ViewTreeObserver.OnGlobalLayoutListener keyboardLayoutListener = new ViewTreeObserver.OnGlobalLayoutListener() {
private int contentDiff;
private int rootHeight;
@Override
public void onGlobalLayout() {
View contentView = getWindow().findViewById(Window.ID_ANDROID_CONTENT);
if (rootHeight != mDrawerLayout.getRootView().getHeight()) {
rootHeight = mDrawerLayout.getRootView().getHeight();
contentDiff = rootHeight - contentView.getHeight();
return;
}
int newContentDiff = rootHeight - contentView.getHeight();
if (contentDiff != newContentDiff) {
if (contentDiff < newContentDiff) {
onShowKeyboard(newContentDiff - contentDiff);
} else {
onHideKeyboard();
}
contentDiff = newContentDiff;
}
}
};
我只是得到一个可以轻视的空白区域,但没有标题或图像。
答案 0 :(得分:5)
最简单的方法是从标签栏中删除图像并设置图像中显示的自定义偏移vertical.as。或者按照TJ3n priveded remove the images in the UITabBarItem and aligned vertically the title的链接。
答案 1 :(得分:0)
如果您希望通过编程方式完成此操作:
tabItem.titlePositionAdjustment = UIOffset(horizontal: 0, vertical: -16)