首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >导航抽屉上的自定义徽章布局显示不正确

导航抽屉上的自定义徽章布局显示不正确
EN

Stack Overflow用户
提问于 2018-10-03 13:34:33
回答 1查看 60关注 0票数 0

我正在处理一个应用程序,在这个应用程序中,我使用自定义的徽章布局作为导航抽屉徽章。但这些数字并没有正确显示:

menu_counter.xml

代码语言:javascript
复制
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ic_circle_outline">

<TextView
    android:id="@+id/counterView"
    android:layout_width="20dp"
    android:layout_height="20dp"
    android:layout_gravity="center"
    android:gravity="center"
    android:text="0"
    android:textColor="@color/red"
    android:textSize="14sp" />

MainActivity.xml

代码语言:javascript
复制
countSideMenu = (TextView) navigationView.getMenu().findItem(R.id.count).getActionView().findViewById(R.id.counterView);
EN

回答 1

Stack Overflow用户

发布于 2018-10-03 13:45:40

用框架布局替换此代码

代码语言:javascript
复制
 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:background="@drawable/ic_circle_outline">

    <TextView
        android:id="@+id/counterView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:gravity="center"
        android:text="0"
        android:textColor="@color/red_dark"
        android:textSize="14sp" />

    </FrameLayout>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52628257

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档