-1
カスタムビューでパスをクリップしようとしていますが、色が黒く表示されます。検索と同じ理由の発見を通して。 "setLayerType(LAYER_TYPE_SOFTWARE,null)
"を設定する必要があることがわかりました。この後は完璧に見えますが、一部ではクラッシュします。ソフトウェアとしてのsetLayerTypeのClipPathがクラッシュする
クラッシュログ(デバイスに基づいて、これらのいずれか):
- java.lang.NegativeArraySizeException
ビットマップは、あなたがこのような何かを行う必要があります32ビット
public class CardLayout extends LinearLayout { private View mRoot; private ImageView mCategoryImageView; private LinearLayout mCategoryBottomView; private RectF mRect; private Paint mPaint; private View mDivider; private Path mPath; private int mPadding = 30; public CardLayout(Context context) { super(context); } public CardLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } public CardLayout(Context context, AttributeSet attrs) { super(context, attrs); mContext = context; mRoot = LayoutInflater.from(getContext()).inflate(R.layout.card_content, null); addView(mRoot); initUI(); } private void initUI() { mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); mPath = new Path(); mCategoryHeadlineTextView = (TextView) mRoot.findViewById(R.id.categoryHeadline); mCategoryImageView = (ImageView) mRoot.findViewById(R.id.categoryImageView); mCategoryBottomView = (LinearLayout) mRoot.findViewById(R.id.ctg_btm_view); mDivider = mRoot.findViewById(R.id.divider); setLayerType(LAYER_TYPE_SOFTWARE,null); } public void setCategoryImage(String categoryUrl) { if (mCategoryImageView != null) { Glide.with(mContext) .load(categoryUrl) .placeholder(R.drawable.two) .into(mCategoryImageView); } } public void setBottomView(String[] optionText, int[] optionResource, int tag) { if (mCategoryBottomView != null) { CategoryBottomOptions options = new CategoryBottomOptions(mContext, optionText, optionResource, tag, mCategoryBottomView); } } @Override protected void dispatchDraw(Canvas canvas) { super.dispatchDraw(canvas); mRect = new RectF(mDivider.getX() - mPadding, mDivider.getY() - mPadding, mDivider.getX() + mPadding, mDivider.getY() + mPadding); mPath.addArc(mRect, 270, 180); canvas.clipPath(mPath); canvas.drawPath(mPath, mPaint); mRect = new RectF(mDivider.getWidth() - mPadding, mDivider.getY() - mPadding, mDivider.getWidth() + mPadding, mDivider.getY() + mPadding); mPath = new Path(); mPath.addArc(mRect, 90, 180); canvas.clipPath(mPath); canvas.drawPath(mPath, mPaint); } }
あなたは救い主です。ありがとうございました。 :) – Niveditha