我想在我的Android应用程序中使用CircularLayout,我正在关注此Circular Layout。
错误:
1) activity_main.xml和content_main.xml未显示任何设计预览。
2)在运行应用时,它显示 很遗憾,应用已停止。
3)logcat显示 ClassNotFoundException。
没有编译错误或警告。
以下是我的logcat:
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: FATAL EXCEPTION: main
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: Process: com.example.shalini.circlelayout, PID: 15699
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.shalini.circlelayout/com.example.shalini.circlelayout.MainActivity}: android.view.InflateException: Binary XML file line #12: Error inflating class com.example.shalini.circlelayout.MainActivity.Activity
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2338)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.app.ActivityThread.access$800(ActivityThread.java:151)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:110)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.os.Looper.loop(Looper.java:193)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5292)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:515)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:828)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:644)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: Caused by: android.view.InflateException: Binary XML file line #12: Error inflating class com.example.shalini.circlelayout.MainActivity.Activity
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:707)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.view.LayoutInflater.parseInclude(LayoutInflater.java:839)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:745)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:255)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at com.example.shalini.circlelayout.MainActivity.onCreate(MainActivity.java:103)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.app.Activity.performCreate(Activity.java:5264)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2302)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.app.ActivityThread.access$800(ActivityThread.java:151)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:110)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.os.Looper.loop(Looper.java:193)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5292)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:515)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:828)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:644)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.shalini.circlelayout.MainActivity.Activity" on path: DexPathList[[zip file "/data/app/com.example.shalini.circlelayout-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.shalini.circlelayout-2, /vendor/lib, /system/lib]]
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.view.LayoutInflater.createView(LayoutInflater.java:559)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.view.LayoutInflater.parseInclude(LayoutInflater.java:839)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:745)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:255)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at com.example.shalini.circlelayout.MainActivity.onCreate(MainActivity.java:103)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.app.Activity.performCreate(Activity.java:5264)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2302)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.app.ActivityThread.access$800(ActivityThread.java:151)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:110)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.os.Looper.loop(Looper.java:193)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5292)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method)
10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:515)
我从中推断出它无法找到类 com.example.shalini.circlelayout.MainActivity.Activity 。
问题:
在这种情况下我们如何处理ClassNotFoundException ?
这就是我的MainActivity.java的样子:
package com.example.shalini.circlelayout;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.AttributeSet;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends AppCompatActivity {
public class Activity extends View {
private final static int TOTAL_DEGREE = 360;
private final static int START_DEGREE = -90;
private Paint mPaint;
private RectF mOvalRect = null;
private int mItemCount = 5;
private int mSweepAngle;
private int mInnerRadius;
private int mOuterRadius;
private Bitmap mCenterIcon;
private int[] mColors = {Color.RED, Color.YELLOW, Color.GREEN, Color.BLUE, Color.CYAN};
private String[] mTitles = {"APPT CENTER", "MEDS CABINET", "CHECK-IN", "MY TRACKERS", "MY ACCOUNTS"};
public Activity(Context context) {
this(context, null);
}
public Activity(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public Activity(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mPaint.setStrokeWidth(2);
mSweepAngle = TOTAL_DEGREE / mItemCount;
mInnerRadius = 125;
mOuterRadius = 400;
mCenterIcon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
}
@Override
protected void onDraw(Canvas canvas) {
int width = getWidth();
int height = getHeight();
if (mOvalRect == null) {
mOvalRect = new RectF(width / 2 - mOuterRadius, height / 2 - mOuterRadius, width / 2 + mOuterRadius, height / 2 + mOuterRadius);
}
for (int i = 0; i < mItemCount; i++) {
int startAngle = START_DEGREE + i * mSweepAngle;
mPaint.setColor(mColors[i]);
mPaint.setStyle(Paint.Style.FILL);
canvas.drawArc(mOvalRect, startAngle, mSweepAngle, true, mPaint);
mPaint.setColor(Color.BLACK);
mPaint.setStyle(Paint.Style.STROKE);
canvas.drawArc(mOvalRect, startAngle, mSweepAngle, true, mPaint);
int centerX = (int) ((mOuterRadius + mInnerRadius) / 2 * Math.cos(Math.toRadians(startAngle + mSweepAngle / 2)));
int centerY = (int) ((mOuterRadius + mInnerRadius) / 2 * Math.sin(Math.toRadians(startAngle + mSweepAngle / 2)));
canvas.drawBitmap(mCenterIcon, width / 2 + centerX - mCenterIcon.getWidth() / 2, height / 2 + centerY - mCenterIcon.getHeight() / 2, null);
mPaint.setColor(Color.BLACK);
mPaint.setStyle(Paint.Style.FILL);
canvas.drawText(mTitles[i], width / 2 + centerX - mCenterIcon.getWidth() / 2, height / 2 + centerY + mCenterIcon.getHeight(), mPaint);
}
mPaint.setColor(Color.WHITE);
mPaint.setStyle(Paint.Style.FILL);
canvas.drawCircle(width / 2, height / 2, mInnerRadius, mPaint);
canvas.drawBitmap(mCenterIcon, width / 2 - mCenterIcon.getWidth() / 2, height / 2 - mCenterIcon.getHeight() / 2, null);
super.onDraw(canvas);
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
这是我的content_main.xml文件:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/lib/com.google.custom"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:showIn="@layout/activity_main" tools:context=".MainActivity">
<com.example.shalini.circlelayout.MainActivity.Activity
android:id="@+id/pie"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
custom:dividerWidth="5dp"
custom:innerCircle="@drawable/profile_pic_icon"
custom:innerRadius="50dp"
custom:layoutMode="pie"
custom:sliceDivider="@android:color/transparent" >
<RelativeLayout
android:id="@+id/appt_center_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ic_launcher1" >
<TextView
android:id="@+id/one"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/appcenter"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ic_launcher2" >
<TextView
android:id="@+id/two"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="@string/medscabinet"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ic_launcher3" >
<TextView
android:id="@+id/three"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="@string/cjeckin"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ic_launcher4" >
<TextView
android:id="@+id/four"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="@string/mytrackers"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ic_launcher5" >
<TextView
android:id="@+id/five"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="@string/myaccounts"
android:textStyle="bold" />
</RelativeLayout>
</com.example.shalini.circlelayout.MainActivity.Activity>
</RelativeLayout>
这是activity_main.xml文件:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:fitsSystemWindows="true"
tools:context=".MainActivity">
<android.support.design.widget.AppBarLayout android:layout_height="wrap_content"
android:layout_width="match_parent" android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar android:id="@+id/toolbar"
android:layout_width="match_parent" android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary" app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_main" />
<android.support.design.widget.FloatingActionButton android:id="@+id/fab"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom|end" android:layout_margin="@dimen/fab_margin"
android:src="@android:drawable/ic_dialog_email" />
</android.support.design.widget.CoordinatorLayout>
答案 0 :(得分:1)
创建外部类YourNewView extends View
但不是Activity extends View
。
在xml
中设为<com.example.shalini.circlelayout.YourNewView
无论您在新圆形布局中使用id,都会使用YourNewView
试试吧。
public class YourNewView extends View {
private final static int TOTAL_DEGREE = 360;
private final static int START_DEGREE = -90;
private Paint mPaint;
private RectF mOvalRect = null;
private int mItemCount = 5;
private int mSweepAngle;
private int mInnerRadius;
private int mOuterRadius;
private Bitmap mCenterIcon;
private int[] mColors = {Color.RED, Color.YELLOW, Color.GREEN, Color.BLUE, Color.CYAN};
private String[] mTitles = {"APPT CENTER", "MEDS CABINET", "CHECK-IN", "MY TRACKERS", "MY ACCOUNTS"};
public YourNewView (Context context) {
this(context, null);
}
public YourNewView (Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public YourNewView (Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mPaint.setStrokeWidth(2);
mSweepAngle = TOTAL_DEGREE / mItemCount;
mInnerRadius = 125;
mOuterRadius = 400;
mCenterIcon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
}
@Override
protected void onDraw(Canvas canvas) {
int width = getWidth();
int height = getHeight();
if (mOvalRect == null) {
mOvalRect = new RectF(width / 2 - mOuterRadius, height / 2 - mOuterRadius, width / 2 + mOuterRadius, height / 2 + mOuterRadius);
}
for (int i = 0; i < mItemCount; i++) {
int startAngle = START_DEGREE + i * mSweepAngle;
mPaint.setColor(mColors[i]);
mPaint.setStyle(Paint.Style.FILL);
canvas.drawArc(mOvalRect, startAngle, mSweepAngle, true, mPaint);
mPaint.setColor(Color.BLACK);
mPaint.setStyle(Paint.Style.STROKE);
canvas.drawArc(mOvalRect, startAngle, mSweepAngle, true, mPaint);
int centerX = (int) ((mOuterRadius + mInnerRadius) / 2 * Math.cos(Math.toRadians(startAngle + mSweepAngle / 2)));
int centerY = (int) ((mOuterRadius + mInnerRadius) / 2 * Math.sin(Math.toRadians(startAngle + mSweepAngle / 2)));
canvas.drawBitmap(mCenterIcon, width / 2 + centerX - mCenterIcon.getWidth() / 2, height / 2 + centerY - mCenterIcon.getHeight() / 2, null);
mPaint.setColor(Color.BLACK);
mPaint.setStyle(Paint.Style.FILL);
canvas.drawText(mTitles[i], width / 2 + centerX - mCenterIcon.getWidth() / 2, height / 2 + centerY + mCenterIcon.getHeight(), mPaint);
}
mPaint.setColor(Color.WHITE);
mPaint.setStyle(Paint.Style.FILL);
canvas.drawCircle(width / 2, height / 2, mInnerRadius, mPaint);
canvas.drawBitmap(mCenterIcon, width / 2 - mCenterIcon.getWidth() / 2, height / 2 - mCenterIcon.getHeight() / 2, null);
super.onDraw(canvas);
}
}
请从Activity extends View
MainActivity