-1
A
回答
0
在你的.xml頁面使用此代碼:
<com.xxx.xxx.xxx.RoundedImageView
android:id="@+id/imageView_round"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:scaleType="fitCenter"
android:src="@drawable/doctor" />
對於RoundedImageView
你必須複製粘貼此:
public class RoundedImageView extends ImageView {
public RoundedImageView(Context context) {
super(context);
}
public RoundedImageView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public RoundedImageView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@SuppressLint("DrawAllocation")
@Override
protected void onDraw(Canvas canvas) {
Drawable drawable = getDrawable();
if (drawable == null) {
return;
}
if (getWidth() == 0 || getHeight() == 0) {
return;
}
Bitmap b = ((BitmapDrawable) drawable).getBitmap();
Bitmap bitmap = b.copy(Bitmap.Config.ARGB_8888, true);
int w = getWidth(), h = getHeight();
Bitmap bmm = Bitmap.createScaledBitmap(bitmap, bitmap.getWidth(),
bitmap.getHeight(), true);
Bitmap roundBitmap = getCroppedBitmap(bitmap, w);
canvas.drawBitmap(roundBitmap, 0, 0, null);
}
public static Bitmap getCroppedBitmap(Bitmap bmp, int radius) {
Bitmap sbmp;
if (bmp.getWidth() != radius || bmp.getHeight() != radius)
sbmp = Bitmap.createScaledBitmap(bmp, radius, radius, false);
else
sbmp = bmp;
Bitmap output = Bitmap.createBitmap(sbmp.getWidth(), sbmp.getHeight(),
Config.ARGB_8888);
Canvas canvas = new Canvas(output);
final int color = 0xffa19774;
final Paint paint = new Paint();
final Rect rect = new Rect(0, 0, sbmp.getWidth(), sbmp.getHeight());
paint.setAnti`enter code here`Alias(true);
paint.setFilterBitmap(true);
paint.setDither(true);
canvas.drawARGB(0, 0, 0, 0);
paint.setColor(Color.parseColor("#BAB399"));
canvas.drawCircle(sbmp.getWidth()/2 + 0.7f,
sbmp.getHeight()/2 + 0.7f, sbmp.getWidth()/2 + 0.1f, paint);
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
canvas.drawBitmap(sbmp, rect, rect, paint);
return output;
}
}
我希望這將有助於
0
這可以通過回收站視圖來實現的,如果你要滾動的圖像,以及,水平滾動回收站視圖中,可以使用下面的代碼。
recyclerView.setLayoutManager(new LinearLayoutManager(RecyclerView_Activity.this, LinearLayoutManager.HORIZONTAL, false));
你可以在一個水平佈局添加回收站視圖(圖像)和的TextView(有值+194共享),一旦我們滾動列表上可以設置待發元素在TextView的數。
如果您的要求不是滾動圖像,那麼您可以簡單地在線性佈局中添加圖像,並添加文本視圖來顯示計數。
相關問題
- 1. 如何實現這種Android佈局?
- 2. 如何在android中實現這種佈局?
- 3. 如何在android中創建這種佈局類型
- 4. 如何在android中繪製這種類型的佈局?
- 5. 如何在Android中實現這種佈局?
- 6. 如何在CSS中進行這種佈局?
- 7. 如何實現這種CSS佈局?
- 8. 如何組織這種佈局溢出?
- 9. 如何用CSS實現這種佈局?
- 10. 如何實現這種佈局?
- 11. 如何用CSS實現這種佈局?
- 12. CSS:如何使這種佈局?
- 13. 如何實現這種佈局
- 14. 如何優化這種佈局?
- 15. 我該如何製作這種佈局?
- 16. 如何實現這種佈局?
- 17. 如何實現這種佈局?
- 18. 在iOS中進行佈局 - 如何創建這樣的佈局?
- 19. 我如何在android中執行此佈局
- 20. html佈局問題:如何實現這種佈局?
- 21. 是否可以進行這種佈局?
- 22. 如何使用Android SDK實現這種佈局?
- 23. Android:如何創建這種動態佈局?
- 24. 如何在軌道中組織這種佈局?
- 25. 如何在Flex 4中實現這種佈局?
- 26. 我如何在流星中實現這種嵌套佈局?
- 27. 如何在新模型中實現這種佈局?
- 28. 如何在Interface Builder中實現這種佈局?
- 29. 如何在我的Android應用中創建這種類型的活動佈局?
- 30. 如何在Android上進行這樣的佈局?
使用圓形圖像視圖和'線性佈局「水平。 –