prom85
prom85

Reputation: 17878

Dark activity dialog theme not working

I want to have a dark activity dialog theme, so I define following:

<style name="AppThemeDialogActivityDark" parent="Theme.AppCompat.Dialog">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>

    <!-- dark toolbar + dark popup menu -->
    <item name="toolbarTheme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
    <item name="popupTheme">@style/ThemeOverlay.AppCompat.Dark</item>


    <!-- trying to forcefully set the background and text color -->
    <item name="android:windowBackground">@android:color/background_dark</item>
    <item name="android:textColor">@color/white</item>

    <item name="android:minWidth">320dp</item>

    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
</style>

Activity:

public class FeedbackActivity extends AppCompatActivity
{
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        // darkTheme returns true!!!
        setTheme(MainApp.getPrefs().darkTheme() ? R.style.AppThemeDialogActivityDark : R.style.AppThemeDialogActivity);
        super.onCreate(savedInstanceState);

        mBinding = DataBindingUtil.setContentView(this, R.layout.activity_feedback);
    }
}

Layout:

<?xml version="1.0" encoding="utf-8"?>
<layout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    xmlns:app="http://schemas.android.com/apk/res-auto" >

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            android:elevation="4dp"
            app:theme="?toolbarTheme"/>

        <ListView
            android:padding="12dp"
            android:id="@+id/lvFeedback"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <ScrollView
            android:id="@+id/svFeedback"
            android:layout_width="wrap_content"
            android:layout_weight="1"
            android:layout_height="0dp">

                <TextView
                    android:padding="12dp"
                    android:id="@+id/tvFeedback"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" />

        </ScrollView>

        <Button
            android:padding="12dp"
            android:id="@+id/btButton"
            style="?borderlessButtonStyle"
            android:elevation="4dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

    </LinearLayout>

</layout>

What am I missing here? Why does my activity dialog have a white background instead of the dark one???

EDIT - Interesting details

Upvotes: 3

Views: 1777

Answers (1)

Olena Y
Olena Y

Reputation: 233

Try to change parent parent="@android:style/Theme.Material.Dialog.Alert"

Upvotes: 1

Related Questions