android - android - 如何将操作栏大小放在尺寸资源文件中
问题描述
我需要在维度资源文件夹中有操作栏大小,我需要为不同的 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>
推荐阅读
- php - Laravel 从 5.8 到 6 更新项目的问题
- reactjs - 对内容繁重的页面做出反应预加载建议
- bigcommerce - 自定义页面的 URL 映射
- toolchain - 安装 PlatformIO 后如何安装 ESP-IDF?
- python - 如果不应该等待,为什么 Python 会等待?
- function - 需要帮助来创建一个空函数
- javascript - 无法读取数组中对象的属性标题
- .htaccess - htaccess - 从 url 末尾删除 .jpg,然后处理所有重写规则
- angular - 具有多个剑道自动完成字段的单页
- mysql - MyISAM 表中的 count(*) 太慢了