Inactive work theme theme
I want to have a dark dialog theme, so I define the 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);
}
}
Markup:
<?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 a dark one ???
EDIT - Interesting details
- Setting up background images
android:background="?android:windowBackground"
doesn't work. But I have to do this for the ListView and for the TextView. That this theme attribute works, theme is applied correctly, it seems that the default background is defined in another theme attribute in the dialog theme? - My tags
ListView
are correct as well, just usingandroid.R.layout.simple_list_item_1
as layout, I don't have to set their background / text colors, they are for dark theme correctly, but do not display if I don 't set backgroundListView
manually as above
+3
source to share