我需要在dimens resources文件夹中有actionbar大小,不同的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>