1
对于选项卡布局,正在对自定义布局进行充气custom_tab.xml,其中徽章视图在名称长度增加时被切断。自定义tabLayout徽章视图正在切断[Android]
我已经试过WRAP_CONTENT所有视图,仍然没有效果
这是custom_tab.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_margin="5dp"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="title"
android:textColor="@color/white"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="@+id/tv_count"
android:layout_width="31dp"
android:layout_height="31dp"
android:layout_gravity="center"
android:layout_margin="5dp"
android:background="@drawable/badge_drawable"
android:gravity="center"
android:textColor="#000000"
android:textSize="12sp" />
</LinearLayout>
这是充气的意见tablayout
private void setupTabIcons() {
for (int i = 0; i < NewFragment.categories.size(); i++) {
try {
LinearLayout currentTabLayout = (LinearLayout) LayoutInflater.from(this).inflate(R.layout.custom_tab, null);
..............................
..............................
tabLayout.getTabAt(i).setCustomView(currentTabLayout);
} catch (Exception e) {
e.printStackTrace();
}
}
}
Java代码
将单行设置为长度增加的文本的屏幕快照假
屏幕截图的文字已经增加长度设置为真
单行这两种情况下,削减从我希望文本视图布局 徽章视图是单线。
谁能帮我解决这个问题。
任何形式的帮助或建议将不胜感激。
感谢
嗨,Sanoop你可以尝试修复该问题使用“选取框”属性设置为1行,因为你的文字很长 –
@DileepPatel感谢您的答复,我都试过,但对徽章来看,它仍然从视图 – Sanoop
隐藏我想,如果文本太长,以适应这是不可能的影响不大,选项卡布局将尝试适合3个选项卡,如果模式设置为“固定”,我不得不将文本缩小为t他同样的要求 –