Issue
I'm trying to build a circular image view but when I build the project there is an error occurring with some of the attributes:

I don't know how to solve it. Maybe it's a lack of some additional libraries in build.gradle? My layout code is shown below:
<RelativeLayout 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"
tools:context="pl.educativo.diagonalcutview.MainActivity">
<RelativeLayout
android:id="@+id/background"
android:layout_width="match_parent"
android:layout_height="300dp"
android:background="@drawable/activity_background" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/background"
android:layout_marginStart="20dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="-100dp">
<ImageView
android:layout_width="150dp"
android:layout_height="150dp"
android:src="@drawable/bebe2"
android:civ_border="true"
android:civ_border_color="@color/semiTransparentWhite"
android:civ_border_width="10dp"
android:contentDescription="TODO" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginStart="12dp"
android:layout_marginEnd="12dp"
android:layout_marginBottom="24dp"
android:layout_gravity="bottom">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-light"
android:text="@string/bebe_rexha"
android:textSize="30sp"
android:textColor="@android:color/black"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-light"
android:text="musician, singer, songwriter"
android:textSize="14sp"/>
</LinearLayout>
</LinearLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:layout_marginTop="24dp"
app:theme="@style/TransparentBar">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-light"
android:gravity="center_vertical"
android:text="About"
android:textSize="24sp" />
</android.support.v7.widget.Toolbar>
</RelativeLayout>
Solution
Use this Library in App level build.gradle file
implementation 'de.hdodenhof:circleimageview:2.1.0'
Its would be used like this
<de.hdodenhof.circleimageview.CircleImageView xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/img_user"
android:layout_width="150sp"
android:layout_height="150sp"
android:layout_centerHorizontal="true"
android:src="@drawable/ic_driver"
app:civ_border_color="@color/colorWhite"
app:civ_border_width="2dp"
app:civ_fill_color="@color/colorWhite20" />
It has many more other attributes you can check them on:
https://github.com/hdodenhof/CircleImageView
Answered By - Abdur Rahman
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.