我的导航视图在我的应用程序的某个屏幕中忽略了它的视图的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
发布评论