Toast text out of alignment

0

I'm working on a small project for college and I came across this when using a toast:

Ihavenoideawhatmadethetoastlooklikethis.Hasanyoneeverhadasimilarproblem?

Edition:ThisisthecodeI'musingtocreateToast:

Toast.makeText(Singleton.getInstance().getContext(),"Nota criada com sucesso!", Toast.LENGTH_SHORT).show();

I noticed that the error appeared after I installed the SystemBarTint library. Before using it, I had tried to get the same result using only XML files, but I was not satisfied. Could anything in this be influencing? This is my styles.xml current:

<resources>

    <style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
        <item name="android:actionBarStyle">@style/Notas.ActionBar</item>
        <item name="android:actionBarWidgetTheme">@style/Notas.ActionBar.OverflowMenu</item>
        <item name="android:fitsSystemWindows">true</item>
        <item name="android:clipToPadding">true</item>
        <item name="android:windowTranslucentStatus">true</item>
    </style>

    <style name="Notas.ActionBar" parent="@android:style/Widget.Holo.ActionBar">
        <item name="android:background">@color/roxo</item>
        <item name="android:titleTextStyle">@style/Notas.ActionBar.TitleTextStyle</item>
    </style>

    <style name="Notas.ActionBar.TitleTextStyle" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
        <item name="android:textColor">@color/branco</item>
    </style>

    <style name="Notas.ActionBar.OverflowMenu" parent="android:Theme.Holo.Light">
        <item name="android:popupMenuStyle">@android:style/Widget.Holo.Light.PopupMenu</item>
        <item name="android:dropDownListViewStyle">
            @android:style/Widget.Holo.Light.ListView.DropDown
        </item>
    </style>
</resources>
    
asked by anonymous 12.10.2014 / 23:09

1 answer

2

The problem is that the android:fitsSystemWindows attribute is specific for View's statements in xml layout, not for themes.

If you want to keep the theme with this attribute, a "workaround" would use getApplicationContext() or getApplication() , as context for makeText . This way:

// Se estiver dentro de uma Activity
Toast.makeText(getApplicationContext(), "Nota criada com sucesso!", Toast.LENGTH_SHORT).show();

// ou

Toast.makeText(getApplication(), "Nota criada com sucesso!", Toast.LENGTH_SHORT).show();

Ideally, you should move the android:fitsSystemWindows attribute to every View that is the root of your layouts.

More information: Android AOSP Issue 63653 .

    
13.10.2014 / 03:13