Android 4.x

系统教程 行业动态 更新时间:2024-06-14 16:53:07
Android 4.x - NavigationView忽略android:主题参数(Android 4.x - NavigationView ignores android:theme parameter)

我的导航视图在我的应用程序的某个屏幕中忽略了它的视图的android:theme参数。 特定屏幕是搜索窗口,其中包括工具栏内的编辑文本视图。 此问题仅适用于4.x设备。 似乎导航视图只忽略参数android:textSize。

链接到两个图像。 包含较小字体的图像是所描述的导航视图,其部分地忽略了android:theme参数。

这是我在全球范围内使用的导航视图:

<?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.NavigationView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/nav_view" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" android:background="@color/nav_background" android:fitsSystemWindows="true" android:theme="@style/AppTheme.Drawer" app:itemBackground="@drawable/nav_item_selector_background" app:itemTextColor="@color/nav_default_text_color" app:menu="@menu/navigation_drawer" />

这是连接到android:主题的样式:

<style name="AppTheme.Drawer"> <item name="android:textSize">25sp</item> <!-- menu item text size--> <item name="android:listPreferredItemHeightSmall">70dp</item><!-- menu item height--> </style>

有没有人有任何想法,为什么会发生这种行为? 此外,我的导航视图有时相当滞后,没有任何理由。 在打开或关闭抽屉时,我不做任何计算。

My navigation view ignores partly the android:theme parameter of it's view in a certain screen of my app. The certain screen is a search window which includes an edit text view inside the toolbar. This issue only exists for the 4.x devices. It seems like the navigation view only ignores the parameter android:textSize.

Link to the two images. The image including the smaller font is the described navigation view which ignores the android:theme parameter partly.

That's the navigation view which I'm using globally:

<?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.NavigationView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/nav_view" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" android:background="@color/nav_background" android:fitsSystemWindows="true" android:theme="@style/AppTheme.Drawer" app:itemBackground="@drawable/nav_item_selector_background" app:itemTextColor="@color/nav_default_text_color" app:menu="@menu/navigation_drawer" />

That's the style which is connected to the android:theme:

<style name="AppTheme.Drawer"> <item name="android:textSize">25sp</item> <!-- menu item text size--> <item name="android:listPreferredItemHeightSmall">70dp</item><!-- menu item height--> </style>

Does anyone has any ideas why this behavior could happen? Additionally my navigation view is sometimes quite laggy without reasons. I don't do any calculation while opening or closing this drawer.

最满意答案

我发现我的问题。 我正在使用super.onCreate(savedInstanceState); 在我使用这些方法来设置内容视图和工具栏之后。 这似乎是Android 5.0+没有问题,但旧设备。

I found my problem. I was using super.onCreate(savedInstanceState); after I used the methods to set the content view and toolbar. It seems like that Android 5.0+ has no problems with that but older devices do.

更多推荐

android,view,视图,导航,电脑培训,计算机培训,IT培训"/> <meta name="descriptio

本文发布于:2023-04-05 21:05:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/d28578b570fe8436120cf4a51d3aa87e.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!