1

For four days I'm trying to use this project in my application. By now I created a new, clean project and I was trying to run sample, but the project was from Eclipse, and I'm working on Android Studio. Anyway, I don't want to import the whole project, just want to copy necessary files.

First I'm creating a libs folder where I put the circularimageview.jar file - is it a difference between a file from CircularImageView and CircularImageViewSample dir?

Then I add this as a library from the Android Studio, so finally I'm getting:

compile 'com.android.support:support-v4:23.0.1'

compile 'com.android.support:appcompat-v7:23.0.1'

compile files(':circularImageView')

in build.gradle.

Next, I'm adding to my activity_main.xml the code from author's site, so it looks like http://pastebin.com/qetJBG6F

Should I change the

xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/libs/com.mikhaellopez.circularimageviewsample" 

lines?

I'm adding the java code from author's site so my MainActivity.java looks like:

package info.androidhive.kolka;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

import com.mikhaellopez.circularimageview.CircularImageView;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        CircularImageView circularImageView = (CircularImageView)findViewById(R.id.avatar);
        circularImageView.setBorderColor(getResources().getColor(R.color.GrayLight));
        circularImageView.setBorderWidth(10);
        circularImageView.addShadow();
    }

What am I missing, why I'm still getting an errors such as

Error:(8) No resource identifier found for attribute 'border' in package 'com.mikhaellopez.circularimageviewsample'or java.lang.RuntimeException: Unable to start activity ComponentInfo{info.androidhive.kolka/info.androidhive.kolka.MainActivity}: android.view.InflateException: Binary XML file line #8: Error inflating class com.mikhaellopez.circularimageview.CircularImageView

?

Greetings

jarlh
  • 42,561
  • 8
  • 45
  • 63
krzk
  • 363
  • 5
  • 14
  • @Raghunandan I've got this "compile fileTree(include: ['*.jar'], dir: 'libs')" – krzk Sep 14 '15 at 08:58
  • ok then it seems to be problem with the library project. Is there a sample by the author? – Raghunandan Sep 14 '15 at 09:00
  • You should try thiis " compile 'de.hdodenhof:circleimageview:1.3.0' " instead of compiling the jar – Tosin Onikute Sep 14 '15 at 09:07
  • What are you asking excactly? I'm adding a CircularImageView.jar from the direct dir, not from CircularImageViewSample dir. @Raghunandan – krzk Sep 14 '15 at 09:07
  • @krzk its a module and i tried the library myself. works fine. all i had is this `compile project(':circularImageView')` and i used file import new module to import the module in my project – Raghunandan Sep 14 '15 at 09:19
  • @HtmlTosin Didn't help, but I'm getting other error http://pastebin.com/KQhggmSJ I have never done this before so I'm suspecting I'm doing something wrong... – krzk Sep 14 '15 at 09:20
  • Ok, all you want to do is to make a rounded image right? – Tosin Onikute Sep 14 '15 at 09:21
  • @HtmlTosin Yes. This was supposed to be the easiest way to do that. – krzk Sep 14 '15 at 09:24
  • @krzk the cause is this **Caused by: java.lang.NoClassDefFoundError: com.mikhaellopez.circularimageview.R$attr** which means you haven't referenced the module properly – Raghunandan Sep 14 '15 at 09:24
  • adding only jar is not sufficient , may be you need to put attr.xml in library project. – MohK Sep 14 '15 at 11:06

1 Answers1

0

I think there may be something wrong with the Library, It didn't work when I tried it either. but you could still achieve a round image, but for extras like BorderColor, borderWidth, You could read this

Android Drop Shadow on View,

Add Frame or Border to ImageView and Drop-Shadow and this

Custom ImageView with drop shadow

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        This code doesn't seem to work
       /* CircularImageView circularImageView = (CircularImageView)findViewById(R.id.avatar);
        circularImageView.setBorderColor(getResources().getColor(R.color.GrayLight));
        circularImageView.setBorderWidth(10);
        circularImageView.addShadow(); */

                ImageView myimage = (ImageView) this.findViewById(R.id.imageId);

                Glide.with(MainActivity.this)
                .load(R.drawable.myphoto)
                .fitCenter()
                .into(myimage);
    }

The Layout

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_vertical">
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <de.hdodenhof.circleimageview.CircleImageView
            android:id="@+id/imageId"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="16dp"
            android:src="@drawable/myimage"
            />

    </LinearLayout>

</LinearLayout>

Build.graddle app

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'de.hdodenhof:circleimageview:1.3.0'
    compile 'com.github.bumptech.glide:glide:3.6.0'
}
Community
  • 1
  • 1
Tosin Onikute
  • 3,883
  • 6
  • 38
  • 61