形状圆矩形太大,无法渲染到android中的纹理

时间:2013-12-18 17:09:40

标签: android performance android-layout gridview

我正在为自定义gridview使用自定义形状。

网格视图属性:

<com.View.UI.ExpandableHeightGridView
    android:id="@+id/issueList"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/archiveTitle"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:background="@drawable/customshape"
    android:numColumns="3"
    android:overScrollMode="never"
    android:scrollbars="none"
    android:isScrollContainer="false"
/>

自定义类扩展gridview(用于在元素添加到gridview时增加高度)

public class ExpandableHeightGridView extends GridView{
    boolean expanded = false;

    public ExpandableHeightGridView(Context context)
    {
        super(context);
    }

    public ExpandableHeightGridView(Context context, AttributeSet attrs)
    {
        super(context, attrs);
    }

    public ExpandableHeightGridView(Context context, AttributeSet attrs,
            int defStyle)
    {
        super(context, attrs, defStyle);
    }

    public boolean isExpanded()
    {
        return expanded;
    }

    @Override
    public void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
    {   
        if (isExpanded())
        {
            // Calculate entire height by providing a very large height hint.
            // View.MEASURED_SIZE_MASK represents the largest height possible.
            int expandSpec = MeasureSpec.makeMeasureSpec(MEASURED_SIZE_MASK,
                    MeasureSpec.AT_MOST);
            super.onMeasure(widthMeasureSpec, expandSpec);

//            ViewGroup.LayoutParams params = getLayoutParams();
//            params.height = getMeasuredHeight();
        }
        else
        {
            super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        }
    }

    public void setExpanded(boolean expanded)
    {
        this.expanded = expanded;
    }
}

还有custom_shape.xml

<solid android:color="#FFF" />

<stroke
    android:width="1dp"
    android:color="#808080" />

<corners android:radius="10dp" />

它可以在我的手机上运行(更多新功能),但是当它在旧平板电脑上运行时显示Shape round rect too large to be rendered into a texture,它是一个网格视图而不是包含~40元素,所以它可能很高。

如何解决?

0 个答案:

没有答案