我绝对是Android的初学者。现在我正在学习如何设计Android应用程序。所以现在我正在尝试使用CircleImageView。我用gradle安装它。但是当我在布局文件中使用它时,它会抛出错误。
这是我的带有CircleImageView的xml布局文件:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimaryDark"
android:padding="16dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark"
android:orientation="vertical"
android:gravity="bottom">
<CircleImageView
android:src="@drawable/calendar"
android:layout_width="50dp"
android:layout_height="50dp" />
<TextView
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="Your to-do list"
android:textColor="@android:color/white"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"/>
</LinearLayout>
这是我在Gradle中使用compile安装CircleImageView的方法:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.waiyanhein.todo.todo"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'de.hdodenhof:circleimageview:1.3.0'
}
但是当我运行它时,它会抛出错误。
这是Logcat:
01-28 08:54:08.499 29509-29509/com.waiyanhein.todo.todo D/AndroidRuntime: Shutting down VM
01-28 08:54:08.499 29509-29509/com.waiyanhein.todo.todo W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0xa6152908)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: FATAL EXCEPTION: main
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.waiyanhein.todo.todo/com.waiyanhein.todo.todo.MainActivity}: android.view.InflateException: Binary XML file line #32: Error inflating class android.support.design.widget.NavigationView
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.app.ActivityThread.access$600(ActivityThread.java:141)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.os.Looper.loop(Looper.java:137)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5041)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:511)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: Caused by: android.view.InflateException: Binary XML file line #32: Error inflating class android.support.design.widget.NavigationView
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.view.LayoutInflater.createView(LayoutInflater.java:613)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:256)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at com.waiyanhein.todo.todo.MainActivity.onCreate(MainActivity.java:46)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.app.Activity.performCreate(Activity.java:5104)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.app.ActivityThread.access$600(ActivityThread.java:141)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.os.Looper.loop(Looper.java:137)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5041)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:511)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: Caused by: java.lang.reflect.InvocationTargetException
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at java.lang.reflect.Constructor.constructNative(Native Method)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.view.LayoutInflater.createView(LayoutInflater.java:587)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:256)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at com.waiyanhein.todo.todo.MainActivity.onCreate(MainActivity.java:46)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.app.Activity.performCreate(Activity.java:5104)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.app.ActivityThread.access$600(ActivityThread.java:141)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.os.Looper.loop(Looper.java:137)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5041)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:511)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class CircleImageView
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:698)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.support.design.internal.NavigationMenuPresenter.inflateHeaderView(NavigationMenuPresenter.java:190)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.support.design.widget.NavigationView.inflateHeaderView(NavigationView.java:250)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.support.design.widget.NavigationView.<init>(NavigationView.java:172)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.support.design.widget.NavigationView.<init>(NavigationView.java:94)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at java.lang.reflect.Constructor.constructNative(Native Method)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.view.LayoutInflater.createView(LayoutInflater.java:587)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:256)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at com.waiyanhein.todo.todo.MainActivity.onCreate(MainActivity.java:46)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.app.Activity.performCreate(Activity.java:5104)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.app.ActivityThread.access$600(ActivityThread.java:141)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.os.Looper.loop(Looper.java:137)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5041)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:511)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.CircleImageView" on path: /data/app/com.waiyanhein.todo.todo-1.apk
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.view.LayoutInflater.createView(LayoutInflater.java:552)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.view.LayoutInflater.onCreateView(LayoutInflater.java:643)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.support.design.internal.NavigationMenuPresenter.inflateHeaderView(NavigationMenuPresenter.java:190)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.support.design.widget.NavigationView.inflateHeaderView(NavigationView.java:250)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.support.design.widget.NavigationView.<init>(NavigationView.java:172)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.support.design.widget.NavigationView.<init>(NavigationView.java:94)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at java.lang.reflect.Constructor.constructNative(Native Method)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.view.LayoutInflater.createView(LayoutInflater.java:587)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:256)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at com.waiyanhein.todo.todo.MainActivity.onCreate(MainActivity.java:46)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.app.Activity.performCreate(Activity.java:5104)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.app.ActivityThread.access$600(ActivityThread.java:141)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.os.Looper.loop(Looper.java:137)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5041)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:511)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
01-28 08:54:08.503 29509-29509/com.waiyanhein.todo.todo E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method)
我的代码出了什么问题,是否正确使用它?
答案 0 :(得分:1)
将CircleImageView
替换为de.hdodenhof.circleimageview.CircleImageView
最终代码
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimaryDark"
android:padding="16dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark"
android:orientation="vertical"
android:gravity="bottom">
<de.hdodenhof.circleimageview.CircleImageView
android:src="@drawable/calendar"
android:layout_width="50dp"
android:layout_height="50dp" />
<TextView
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="Your to-do list"
android:textColor="@android:color/white"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"/>
</LinearLayout>
答案 1 :(得分:-1)
de.hdodenhof.circleimageview.CircleImageView
到<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimaryDark"
android:padding="16dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark"
android:orientation="vertical"
android:gravity="bottom">
<de.hdodenhof.circleimageview.CircleImageView
android:src="@drawable/calendar"
android:layout_width="50dp"
android:layout_height="50dp" />
<TextView
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="Your to-do list"
android:textColor="@android:color/white"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"/>
</LinearLayout>
中
如下所示
{{1}}