Android toolbar overflow menu text display is incomplete

I have only been in touch with android for a few days, and the configuration of android is almost based on the feeling.
Therefore, there is a problem, as shown in the following figure, the text of the drop-down box group of toolbar overflow menu is not completely displayed:

After many attempts, it turns out that there is a problem with the configuration of the toolbar, as shown in the following figure:

You can see two important style configurations:
1. app:popupTheme
2. app:theme

Change it to:

Modify the styles.xml under the value package

<resources xmlns:tools="http://schemas.android.com/tools">
    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>
   <!-- <style name="OverflowMenuStyle" >
    &lt;!&ndash; Override anchor, default istrue´╝îCover up Toolbar &ndash;&gt;
    <item name="overlapAnchor">false</item>
    &lt;!&ndash; Pop up layer background color &ndash;&gt;
    <item name="android:popupBackground">@color/colorPrimary</item>
    &lt;!&ndash; The offset in the vertical direction of the flyout layer, that is, the distance in the vertical direction Toolbar A negative value will cover the Toolbar &ndash;&gt;
    <item name="android:dropDownVerticalOffset">500dp</item>
    &lt;!&ndash; The offset in the horizontal direction of the pop-up layer, that is, the distance from the left side of the screen. A negative value will cause a gap on the right side &ndash;&gt;
    <item name="android:dropDownHorizontalOffset">0dp</item>
    <item name="android:textColor">@color/text_blue</item>
</style>-->
    <style name="AppTheme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>

    <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
    <style name="AppTheme.PopupOverlay" parent="@style/Widget.AppCompat.Light.PopupMenu.Overflow">
        <item name="overlapAnchor">false</item>
        <item name="android:dropDownWidth">wrap_content</item>
        <item name="android:paddingRight">5dp</item>
        <item name="android:popupBackground">?attr/colorPrimary</item>
        <!-- The offset in the vertical direction of the flyout layer, that is, the distance in the vertical direction Toolbar A negative value will cover the Toolbar -->
        <item name="android:dropDownVerticalOffset">5dip</item>
        <!-- The offset in the horizontal direction of the pop-up layer, that is, the distance from the left side of the screen. A negative value will cause a gap on the right side -->
        <item name="android:dropDownHorizontalOffset">0dip</item>
    </style>
</resources>

Design sketch:

Conclusion:
1. In fact, the setting of style involves the problem of scope, that is, which style file has a stronger scope. I used to configure the style of overflow menu in android:theme style file of Android manifest.xml, and the result can't show all the text. That is, the style file of the red box in the following figure:

In fact, the attributes it sets should be overwritten by the toolbar style file. You can think of the scope of CSS style setting. The closer you are to a div, the more distant the style will be covered.

Tags: Android xml

Posted on Sun, 09 Feb 2020 09:44:24 -0500 by Mehdi