views:

29

answers:

1

I have an Activity that contains a FrameLayout and two views. The first is a ViewFlipper and the second is an ImageView. If I comment out the ViewFlipper, the activity renders the ImageView and its background correctly, but when the ViewFlipper is visible, the ImageView's background is completely ignored.

Is this a "feature" of ViewFlipper? Is there a way I can work around this?

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
       android:layout_width="fill_parent"
       android:layout_height="fill_parent"
       android:background="@android:color/background_light"
       >        
    <ViewFlipper android:id="@+id/flipper"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       android:flipInterval="5000"
       >
                <include layout="@layout/cell_1" android:id="@+id/cell_1"/>
                <include layout="@layout/cell_2" android:id="@+id/cell_2"/>
                <include layout="@layout/cell_3" android:id="@+id/cell_3"/>
   </ViewFlipper>
    <ImageView
        android:background="@drawable/alpha_gradient_background"
        android:id="@+id/statusIcon"
        android:src="@drawable/status_icon"
        android:padding="5dp"
        android:layout_gravity="right"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:top="10dp"
        android:right="10dp"
        />
</FrameLayout> 

And my background drawable looks like this:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
   android:shape="rectangle">
    <stroke android:width="3dp" android:color="#ffff0000" />
    <gradient
         android:startColor="#66660000"
         android:centerColor="#66006600"
         android:endColor="#66000066"
         android:angle="270" 
    />
</shape>
A: 

It appears that Buttons are able to render their background when placed over a ViewFlipper.

I have therefore got around this by creating a partially transparent PNG and setting that as the background image on the button.

Net Wolf