繁体   English   中英

android - 如何将操作栏大小放入尺寸资源文件中

[英]android - how to put actionbar size in dimens resources file

我需要在 dimens 资源文件夹中设置操作栏大小,我需要为不同的 api 版本设置不同的大小。

我已经尝试了这些代码,但都遇到了错误:

?android:attr/actionBarSize
?attr/actionBarSize
?actionBarSize

当我启动应用程序时,我收到此错误:

 You must supply a layout_height attribute.

如何将操作栏大小放在资源文件夹中?

这对我有用:

<androidx.appcompat.widget.Toolbar
    :
    android:layout_height="?attr/actionBarSize"
    android:theme="@style/AppBarTheme" />

和:

<style name="AppBarTheme" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
    :
</style>

编辑:我也有这个:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Using the toolbar so no need to show action bar or title -->
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    :
</style>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM