Domanda

I use the following shape as a background for various layouts to logically group data within my app.

<?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android" 
         android:shape="rectangle"> 
         <gradient android:startColor="#A51C4293" android:endColor="#A51C4293" 
                android:angle="180"/> 

         <corners android:bottomRightRadius="7dp" android:bottomLeftRadius="7dp" 
          android:topLeftRadius="7dp" android:topRightRadius="7dp"/> 
     </shape>

One view is a linear layout that is comprised of custom controls added at run time based on the contents of an XML file. The layout is defined as:

<LinearLayout
            android:id="@+id/localDiningLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="32dp"
            android:layout_marginLeft="0dp"
            android:layout_marginRight="0dp"
            android:layout_marginTop="16dp"
            android:orientation="vertical"
            android:paddingLeft="8dp"
            android:paddingRight="8dp" >

            <TextView
                android:id="@+id/localDiningLabel"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="8dp"
                android:layout_marginLeft="0dp"
                android:layout_marginRight="0dp"
                android:layout_marginTop="8dp"
                android:gravity="center_vertical|center_horizontal"
                android:paddingLeft="0dp"
                android:text="Local Dining"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:textColor="@color/plainText" />
        </LinearLayout>

And the code to add the controls is:

// looping through all item nodes <item>      
        for (int i = 0; i < nl.getLength(); i++) {
            Element e = (Element)nl.item(i); 
            String name = this.parser.getValue(e, "Name");
            String type = this.parser.getValue(e, "Type"); 
            String street = this.parser.getValue(e, "Street"); 
            String city = this.parser.getValue(e, "City"); 
            String state = this.parser.getValue(e, "State"); 
            String distance = this.parser.getValue(e, "Distance"); 
            String website = this.parser.getValue(e, "Website"); 
            String urbanspoon = this.parser.getValue(e, "UrbanSpoon"); 
            String maps = this.parser.getValue(e, "Maps"); 

            DiningElement DE = new DiningElement(C);
            DE.setWebLink(website);
            DE.setUSLink(urbanspoon);
            DE.setNavLink(maps);            
            DE.SetName(name);
            DE.SetType(type);
            DE.SetAddress(street + ", " + city + ", " + state);
            DE.SetDistance(distance);
            DE.loadViews();

            LL.addView(DE);

            if (i < nl.getLength() - 1){
                View ruler = new View(C); 
                ruler.setBackgroundColor(0x33FFFFFF);
                            LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, 1);
                params.setMargins(8, 0, 8, 0);
        ruler.setLayoutParams(params);
                LL.addView(ruler, params);
            }
        }

        LL.setBackgroundResource(R.drawable.nonhotelgroupbubble);
        LL.invalidate();

A draw-able that has rounded corners will not show up in the background. If I remove the rounded corners from the shape, it appears fine. Any suggestions?

Additional info, here is the custom control layout and I am adding ~20 of these.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:orientation="vertical" >

<TextView
    android:id="@+id/nameText"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="2dp"
    android:layout_marginTop="0dp"
    android:text="Name Text"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:textColor="@color/plainText" />

<TextView
    android:id="@+id/typeText"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="2dp"
    android:layout_marginTop="0dp"
    android:text="Type of food"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:textColor="@color/plainText" />

<TextView
    android:id="@+id/addressText"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="2dp"
    android:text="Address"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:textColor="@color/plainText" />

<TextView
    android:id="@+id/distanceText"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="8dp"
    android:text="Distance"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:textColor="@color/plainText" />

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="8dp"
    android:gravity="center" >

    <ImageButton
        android:id="@+id/dining_websiteButton"
        android:layout_width="45dp"
        android:layout_height="45dp"
        android:layout_marginBottom="0dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="16dp"
        android:background="@null"
        android:scaleType="fitXY"
        android:src="@drawable/web" />

    <ImageButton
        android:id="@+id/diningUSButton"
        android:layout_width="45dp"
        android:layout_height="45dp"
        android:layout_marginLeft="16dp"
        android:layout_marginRight="16dp"
        android:background="@null"
        android:scaleType="fitXY"
        android:src="@drawable/urbanspoon" />

    <ImageButton
        android:id="@+id/diningnavButton"
        android:layout_width="45dp"
        android:layout_height="45dp"
        android:layout_marginLeft="16dp"
        android:layout_marginRight="8dp"
        android:background="@null"
        android:scaleType="fitXY"
        android:src="@drawable/nav_arrow" />

</LinearLayout>

</LinearLayout>
È stato utile?

Soluzione

After a fair amount of google research, turning off hardware acceleration was the only workaround found. Set the following in your manifest for the entire application

    <application android:hardwareAccelerated="false" ...>

or for the activity

    <activity android:hardwareAccelerated="false" />
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top