java - 在Android上使用圆形 ImageView

标签 java android

我在 xml 布局上使用圆形 ImageView ,但出现此错误:

Exception Details java.lang.NoClassDefFoundError: de/hdodenhof/circleimageview/R$styleable   at 
 de.hdodenhof.circleimageview.CircleImageView.<init>(CircleImageView.java:91)   at 
 de.hdodenhof.circleimageview.CircleImageView.<init>(CircleImageView.java:85)   
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:858)
at  android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)   
at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)   
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)

我阅读了它的官方网站,并且确实喜欢这个网站,但对我来说没有任何作用。 这是我的 xml 配置布局,我像这个网站一样使用:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_height="match_parent">

<de.hdodenhof.circleimageview.CircleImageView
    android:layout_width="160dp"
    android:layout_height="160dp"
    android:layout_centerInParent="true"
    android:src="@mipmap/ic_launcher"
    app:civ_border_width="2dp"
    app:civ_border_color="@color/colorAccent" />
 </RelativeLayout>

我的网格:

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
 //    compile 'com.android.support:appcompat-v7:23.3.0'
  compile 'com.android.support:appcompat-v7:23.0.1'
  compile 'com.android.support:design:23.0.1'
  compile 'de.hdodenhof:circleimageview:2.1.0'
}

它不会使我的图片带有边框

最佳答案

我检查了这行代码工作得很好,我从您的代码中得到以下输出: enter image description here

Option 1: Clean the project or rebuild the project

选项 2:重新同步 gradle。 enter image description here

Option 3: Update your Android Studio.

如果三个选项中的任何一个不起作用,则说明您的样式文件中存在错误,请检查并更正它们。

关于java - 在Android上使用圆形 ImageView ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41550367/

相关文章:

java - JOOQ 慢速代码生成

java - 我正在为我的应用程序构建 googlemap 跟踪,现在我被困了五天多了,我认为,,简单''问题

android - 错误decodin签名JWT认证Android

android - 如何将布局内容移到屏幕android之外

java - Android 上的 JSoup 1.6.0 抛出异常 : String. isEmpty() NoSuchMethodExists

java - 在另一个干净项目中使用时,自定义 Maven 插件无法解析父 POM

Java:带循环的数组(匹配)

java - 无法在浏览器中打开 WSDL

android - react native : Null extracted folder for artifact: ResolvedArtifact(componentIdentifier=com. facebook.react :react-native:0. 71.0-rc.0)

android - 计算webservice记录的数据库大小