1
A
回答
6
設置填充大小右邊和底部和背景設置你的影子
<ImageView
android:id="@+id/imageview"
android:background="@drawable/drop_shadow"
<!--android:background="#660000"--> This breaks the syntax highlight
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="10px"
android:paddingBottom="10px"
android:src="@drawable/pic1"
/>
4
嘗試使用位圖
public Bitmap imgshadow(final Bitmap bm, final int dstHeight, final int dstWidth, int color, int size, float dx, float dy) {
final Bitmap mask = Bitmap.createBitmap(dstWidth, dstHeight, Config.ALPHA_8);
final Matrix scaleToFit = new Matrix();
final RectF src = new RectF(0, 0, bm.getWidth(), bm.getHeight());
final RectF dst = new RectF(0, 0, dstWidth - dx, dstHeight - dy);
scaleToFit.setRectToRect(src, dst, ScaleToFit.CENTER);
final Matrix dropShadow = new Matrix(scaleToFit);
dropShadow.postTranslate(dx, dy);
final Canvas maskCanvas = new Canvas(mask);
final Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
maskCanvas.drawBitmap(bm, scaleToFit, paint);
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_OUT));
maskCanvas.drawBitmap(bm, dropShadow, paint);
final BlurMaskFilter filter = new BlurMaskFilter(size, Blur.NORMAL);
paint.reset();
paint.setAntiAlias(true);
paint.setColor(color);
paint.setMaskFilter(filter);
paint.setFilterBitmap(true);
final Bitmap ret = Bitmap.createBitmap(dstWidth, dstHeight, Config.ARGB_8888);
final Canvas retCanvas = new Canvas(ret);
retCanvas.drawBitmap(mask, 0, 0, paint);
retCanvas.drawBitmap(bm, scaleToFit, null);
mask.recycle();
return ret;
}
final Bitmap src = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
final Bitmap shadows = imgshadow(src, src.getHeight(), src.getWidth(), Color.BLACK, 3, 1, 3);
final ImageView iv = (ImageView)findViewById(R.id.imageview1);
iv.setImageBitmap(shadows);
相關問題
- 1. 如何給imageview添加陰影?
- 2. OpenGL | ES添加陰影/陰影貼圖
- 3. 如何向UINavigationController添加陰影
- 4. 向滑動抽屜添加陰影
- 5. 添加框架或邊框到ImageView和陰影
- 6. 泰伯維:添加陰影
- 7. 將陰影添加到UIBarButton
- 8. 給圖層添加陰影
- 9. 將陰影添加到UINavigationControllerer
- 10. 添加陰影chart.js之
- 11. DrawRect添加文字陰影
- 12. 在OpenGL中添加陰影
- 13. 用CAShapeLayer添加陰影?
- 14. 將陰影添加到TBitmap
- 15. 添加陰影的MKMapView
- 16. 將陰影添加到PlainTableView?
- 17. 向tableview單元格添加陰影造成滯後滾動和複製陰影
- 18. 向CollapsingToolbar添加反向陰影和高程
- 19. 添加陰影到UITextView的框架也添加陰影到文本
- 20. 添加CSS陰影。陰影僅出現在1側?
- 21. Android:將陰影應用於ImageView底部
- 22. 更改Android上ImageView的陰影顏色
- 23. ImageView上的邊界半徑和陰影
- 24. 我如何向撲動的文字添加陰影?
- 25. 如何向RichTextBox的文本添加陰影c#
- 26. 向CAShapeLayer添加陰影,以便內部保持透明
- 27. 向工具欄分隔線添加陰影
- 28. 如何向Netbeans中的未修飾JFrame添加陰影
- 29. 以編程方式向ShapeDrawable添加陰影
- 30. 添加陰影列以插入語句
http://stackoverflow.com/questions/3693234/custom-imageview-with-drop-shadow – Vyacheslav
任何其他方式上面我提到,如XML @Vyacheslav – YUVRAJ
我不知道創建這個影子,但也許使用卡片視圖幫助你 – Ashkan