Olo*_*ing 7 android android-actionbar android-toolbar
我的问题很简单,但我无法弄清楚:
当我尝试显示字幕时,工具栏没有足够的空间显示它并且它被剪切.
工具栏:
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="?android:actionBarSize"
android:layout_centerHorizontal="true"
app:theme="@style/MyToolBar">
Run Code Online (Sandbox Code Playgroud)
难道?android:actionBarSize没有足够的高度,以显示标题和副标题是否正确?
当我将ToolBar高度设置为wrap_content一切正常时,可以有人向我解释我应该如何正确设置高度?
styles.xml:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:windowBackground">@color/background1</item>
<item name="android:textColorPrimary">@color/colorAccent</item>
<!-- Customize your theme here. -->
</style>
<style name="MyToolBar" parent="Widget.AppCompat.ActionBar">
<!-- Support library compatibility -->
<item name="android:textColorPrimary">@color/colorAccent</item>
<item name="android:textColorSecondary">@color/colorAccent</item>
<item name="colorControlNormal">@color/colorAccent</item>
</style>
Run Code Online (Sandbox Code Playgroud)
我使用了带字幕的工具栏,以及使用layout_height="wrap_content"我还添加了一个minHeight.这将确保您的工具栏至少达到最小高度.我没有看到它跳高或裁剪但我总是有一个字幕设置.
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:elevation="@dimen/default_elevation"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1150 次 |
| 最近记录: |