urbanairship / android-library

Urban Airship Android SDK
Other
109 stars 123 forks source link

Problem overriding the empty message style #214

Closed silviamirandastorm closed 2 years ago

silviamirandastorm commented 2 years ago

Hi Guys.

I'm having a problem overriding the empty message style. (Android lib version 16.6.1) The style I apply doesn't work.

Dosn't center, dosn't apply color correctly

Captura de Tela 2022-09-02 às 17 07 19

am I doing it correctly?

Captura de Tela 2022-09-02 às 17 01 02 Captura de Tela 2022-09-02 às 17 01 11

Ulrico972 commented 2 years ago

Hello, I think you forgot to update the messageCenterStyle also with your style. You can find an example here: https://docs.airship.com/platform/android/message-center/#styling-android-mc

If it still doesn't work, please send us your entire message center style and we'll take a look.

silviamirandastorm commented 2 years ago

Hi the three items are the part that I customized and did not apply Captura de Tela 2022-09-02 às 17 49 56 and here I set Captura de Tela 2022-09-02 às 17 51 01

rlepinski commented 2 years ago

Screenshot_20220902_140209

    <!-- Base application theme. -->
    <style name="AppTheme" parent="BaseTheme">
        ...
        <item name="messageCenterStyle">@style/AppTheme.MessageCenter</item>
    </style>

    <style name="AppTheme.MessageCenter" parent="MessageCenter">
        <item name="messageCenterEmptyMessageText">some really long empty message string</item>
        <item name="messageCenterEmptyMessageTextAppearance">@style/AppTheme.MessageCenter.EmptyMessageTextAppearance</item>
    </style>

    <!-- Custom message title text style -->
    <style name="AppTheme.MessageCenter.EmptyMessageTextAppearance" parent="MessageCenter.EmptyMessage.TextAppearance">
        <item name="android:textSize">44sp</item>
        <item name="android:textColor">#ff00ff</item>
    </style>

A few things, for text color you need to use textColor not color. And unfortunately alignment is not a text appearance attribute. We do not expose that style so you will have to override the actual layout.

Create a new layout titled ua_fragment_message_list.xml with:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
        android:id="@+id/swipe_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ListView
            android:clipToPadding="false"
            android:scrollbarStyle="outsideOverlay"
            android:id="@android:id/list"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

    </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

    <TextView
        android:id="@android:id/empty"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAlignment="center"
        android:gravity="center"
        android:layout_gravity="center" />

</FrameLayout>
silviamirandastorm commented 2 years ago

Ok, thanks ☺️ !

rlepinski commented 2 years ago

Let me know if you have any other issues!