- 註冊時間
- 2013-4-16
- 最後登錄
- 2023-7-6
- 閱讀權限
- 100
- 積分
- 26424
- 精華
- 0
- 帖子
- 8169
|
如何畫沒有背景的圓
How to draw a shape circle
circle.xml- <?xml version="1.0" encoding="utf-8"?>
- <shape
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:shape="oval">
- <solid
- android:color="#eeeeee"/>
- <size
- android:width="120dp"
- android:height="120dp"/>
- </shape>
複製代碼 xxx.java- Drawable shape = ResourcesCompat.getDrawable(_context.getResources(), R.drawable.circle, _context.getTheme());
- TextView tv = new TextView(_context);
- tv.setBackground(shape);
- Broad_frame = new LinearLayout(_context);
- lparams_summary = new LinearLayout.LayoutParams(ballSize, ballSize);
- lparams_summary.setMargins(0, 0, 0, 0);
- Broad_frame.setLayoutParams(lparams_summary);
- Broad_frame.setPadding(0, 0, 0, 0);
- Broad_frame.setOrientation(LinearLayout.HORIZONTAL);
- Broad_frame.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
- Broad_frame.setBackgroundColor(Color.TRANSPARENT);
- Broad_frame.addView(tv);
複製代碼 |
|