我正在使用android支持库BottomNavigationView,它在某些版本的android中看起来非常糟糕。
这是我的代码:
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#fff"
app:theme="@style/mydrawer"
app:itemIconTint="@drawable/selector"
app:itemTextColor="@drawable/selector"
app:menu="@menu/bottom_navigation_items" />
in styles :
<style name="mydrawer">
<item name="android:textSize">14sp</item>
</style>
它在我的Android 6手机中看起来不错,但在大多数手机上看起来都很糟糕,像这样:
正如你所看到的,文字大小巨大
我怎样才能解决这个问题 ?
您为所有设备指定一个文本大小值:
<style name="mydrawer">
<item name="android:textSize">14sp</item>
</style>
而不是14sp,你应该从维度指定值
<style name="mydrawer">
<item name="android:textSize">@dimen/bottom_bar_item_text_size</item>
</style>
为不同的屏幕尺寸创建dimens.xml文件。您应该为每个屏幕大小创建dimens.xml文件:
<dimen name="bottom_bar_item_text_size">14sp</dimen>
您的dimens.xml文件将如下所示:
希望有所帮助
您可以使用Bottom Navigation View Ex进行更多自定义和更好的外观,使用方法与普通视图类似