The subtitle of the toolbar is cut (it does not fit in height)

My question is very simple, but I can not understand:

When I try to display the subtitle , the toolbar is not enough space to display it, and cut it.

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">

Are ?android:actionBarSizethere really not enough heights for the title and subtitles to display correctly ?

When I set ToolBar height to wrap_content, everything works, but can someone explain to me how I should set the height correctly?

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>
+4
source share
3

, 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" />
+1

, . ActionBar java-. .

+1

, ? attr/actionBarSize. , , . , android:layout_height="wrap_content" minHeight . , xml -

<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="wrap_content"
android:minHeight="?attr/actionBarSize"
android:layout_centerHorizontal="true"
app:theme="@style/MyToolBar">
0
source

Source: https://habr.com/ru/post/1629125/


All Articles