views:

631

answers:

0

Hi,

I've got two activities. One is supposed to be a blur in front of the other.

The background activity has several ImageViews which are set up as thin gradients extending across most of the screen and 10dip high. When I start the second activity it sets the background as a gradient occupying the entire window space, that is it appears to be fill_parent'd for both height and width. If I comment out the ImageViews then it blurs and looks as expected.

Any thoughts?

Here's the code doing the blur.

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.view.View.OnClickListener;

public class TransluscentBlurSummaryB extends Activity {
 @Override
    protected void onCreate(Bundle icicle) {
        super.onCreate(icicle);

        getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
                WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
        getWindow().getAttributes().dimAmount = 0.5f;
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND,
          WindowManager.LayoutParams.FLAG_DIM_BEHIND);

        setContentView(R.layout.sheetbdetails);

        OnClickListener clickListener = new OnClickListener() {
            public void onClick(View v) {
             TransluscentBlurSummaryB.this.finish();
            }
        };

        findViewById(R.id.sheetbdetailstable).setOnClickListener(clickListener);

    }
}

And here's the layout with the ImageView gradients.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/summarysparent" >
   <!-- view1 goes on top -->

   <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
        android:id="@+id/view2" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:layout_alignParentBottom="true">   
     <Button android:layout_height="wrap_content" 
      android:id="@+id/ButtonBack" 
      android:layout_width="wrap_content" 
      android:text="Back" 
      android:width="100dp"></Button>
     <Button android:layout_height="wrap_content" 
      android:id="@+id/ButtonNext" 
      android:layout_width="wrap_content" 
      android:layout_alignParentRight="true" 
      android:text="Start Over" 
      android:width="100dp"></Button>
 </RelativeLayout>

    <TextView
        android:id="@+id/view1"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_width="wrap_content" 
        android:layout_centerHorizontal="true" 
        android:textSize="10pt" android:text="Summary"/>

 <ScrollView  xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:id="@+id/summaryscrollview"
     android:layout_below="@+id/view1"
     android:layout_above="@+id/view2">

     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:id="@+id/summarydetails" >

      <!-- view2 goes on the bottom -->

      <TextView android:id="@+id/textview2"
       android:layout_height="wrap_content"
       android:layout_width="wrap_content"
       android:layout_below="@+id/view1"
       android:layout_centerHorizontal="true"
       android:text="Recommended Child Support Order" 
       android:layout_marginTop="10dip" />

      <ImageView
    android:id="@+id/horizontalLine1"
    android:layout_width="fill_parent"
    android:layout_marginLeft="5dip"
    android:layout_marginRight="5dip"
    android:layout_height="10dip"
    android:src="@drawable/black_white_gradient"
    android:layout_below="@+id/textview2"
    android:layout_marginTop="10dip" 
    /> 

      <TextView android:id="@+id/textview3"
       android:layout_height="wrap_content"
       android:layout_width="wrap_content"
       android:layout_below="@+id/horizontalLine1"
       android:layout_centerHorizontal="true"
       android:text="You" 
       android:layout_marginTop="10dip" />

      <TextView android:id="@+id/textview10"
       android:layout_height="wrap_content"
       android:layout_width="150dp"
       android:layout_below="@+id/textview3"
       android:layout_centerHorizontal="true"
       android:layout_marginTop="10dip"
       android:gravity="center_horizontal" />

      <ImageView
    android:id="@+id/horizontalLine2"
    android:layout_width="fill_parent"
    android:layout_marginLeft="5dip"
    android:layout_marginRight="5dip"
    android:layout_height="10dip"
    android:src="@drawable/black_white_gradient"
    android:layout_below="@+id/textview10"
    android:layout_marginTop="10dip" /> 

      <TextView android:id="@+id/textview4"
       android:layout_height="wrap_content"
       android:layout_width="wrap_content"
       android:layout_below="@+id/horizontalLine2"
       android:layout_centerHorizontal="true"
       android:text="Other Parent" 
       android:layout_marginTop="10dip" />

      <TextView android:id="@+id/textview11"
       android:layout_height="wrap_content"
       android:layout_width="150dp"
       android:layout_below="@+id/textview4"
       android:layout_centerHorizontal="true" 
       android:layout_marginTop="10dip" 
       android:text="$536.18" 
       android:gravity="center_horizontal" />

      <ImageView
    android:id="@+id/horizontalLine3"
    android:layout_width="fill_parent"
    android:layout_marginLeft="5dip"
    android:layout_marginRight="5dip"
    android:layout_height="10dip"
    android:src="@drawable/black_white_gradient"
    android:layout_below="@+id/textview11"
    android:layout_marginTop="10dip" /> 

      <TextView android:id="@+id/textview5"
       android:layout_height="wrap_content"
       android:layout_width="wrap_content"
       android:layout_below="@+id/horizontalLine3"
       android:layout_centerHorizontal="true"
       android:text="Calculation Details" 
       android:layout_marginTop="15dip" />

      <ImageView android:id="@+id/infoButton"
       android:src="@drawable/ic_menu_info_details"
       android:layout_height="wrap_content"
       android:layout_width="wrap_content"
       android:layout_below="@+id/horizontalLine3"
       android:layout_toRightOf="@+id/textview5" 
       android:clickable="true"
       />

      <ImageView
    android:id="@+id/horizontalLine4"
    android:layout_width="fill_parent"
    android:layout_marginLeft="5dip"
    android:layout_marginRight="5dip"
    android:layout_height="10dip"
    android:src="@drawable/black_white_gradient"
    android:layout_below="@+id/textview5"
    android:layout_marginTop="18dip" />

  </RelativeLayout>
 </ScrollView>
</RelativeLayout>

The gradient drawable is this.

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
    <gradient 
     android:startColor="#FFFFFF" android:centerColor="#000000" android:endColor="#FFFFFF" 
            android:angle="270"/>
    <padding android:left="7dp" android:top="7dp"
            android:right="7dp" android:bottom="7dp" />
    <corners android:radius="8dp" />
</shape>

And here's the layout from the activity doing the blurring on top.

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
 android:id="@+id/sheetbdetails"
 android:layout_width="fill_parent"
   android:layout_height="fill_parent" 
   android:clickable="true" >
 <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     android:scrollbars="vertical"
     android:shrinkColumns="0"
     android:id="@+id/sheetbdetailstable" >

     <TableRow>
         <TextView

             android:padding="3dip" />
         <TextView
             android:text="You"
             android:padding="3dip" />
         <TextView
             android:text="@string/otherparent"
             android:padding="3dip" />
            <TextView
             android:text="Combined"
             android:padding="3dip" />
     </TableRow>

 </TableLayout>
</ScrollView>

The transparent windows are themed from styles.xml in the apidemos using @style/Theme.Transparent.