我最近更新到AppCompatActivity
,并从ActionBar
切换到ToolBar
。
当我检查xml时,我发现了这两个属性-
android:layout_height="wrap_content"
和
android:minHeight="?attr/actionBarSize"
这两个属性有什么区别?为什么在工具栏文档中将
layout_height
设置为wrap_content
?是否需要同时使用两个属性?
最佳答案
android:layout_height="wrap_content"
和 android:minHeight="?attr/actionBarSize"
这两个属性时,使用较大的图标时,工具栏的高度可能会变大。 android:minHeight
可确保您的工具栏自身的大小不会小于 ?attr/actionBarSize
值。 如果要固定工具栏高度,请使用
android:layout_height="?attr/actionBarSize"
不需要其他属性。