Skip to content Skip to sidebar Skip to footer

Styled Background Used In Layout Of Transparent Popupwindow Not Working

So I have this class that extends PopupWindow. I set the class's background to @android:color/transparent and use the following layout for it's contents:

Solution 1:

Activity is the only Context on which the themes defined in your manifest are actually attached. Any other instance will use the system default theme to inflate your views, leading to a display output you probably didn’t expect.

Context, What Context?

This is why getApplicationContext() will not properly set your theme.

Solution 2:

I ultimately narrowed down the problem to my passing the context returned by getApplicationContext() to the PopupWindow constructor. If I pass LoginActivity.this as the context, things work as expected and I'm able to change backgrounds according to theme selected in the parent activity.

Still beats me why getApplicationContext() would not have the theme I set on it. Food for thought.

Solution 3:

Put tips_root background shap xml in res/drawable. Use android:background instead of style="?Tips_Background" as:

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/tips_root"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="8dip"
    android:orientation="horizontal"
    android:background="@drawable/Tips_Background" >

Post a Comment for "Styled Background Used In Layout Of Transparent Popupwindow Not Working"