I am trying to achieve the following screenshot in android.
To get Round Image I have Round Image Library from here:
https://github.com/vinc3m1/RoundedImageView
So I tried the following code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/marker"
android:orientation="horizontal" >
<com.ylg.RoundImageView
android:id="@+id/profilePhoto"
android:layout_width="80dp"
android:layout_height="80dp"
android:gravity="center_horizontal"
android:src="@drawable/profilepic" />
but I ended up getting error:
NOTE: This project contains Java compilation errors, which can cause rendering failures for custom views. Fix compilation problems first.
Exception raised during rendering: Index: 0, Size: 0
I need 9 patch to my marker image: Which I did below:
What could be wrong here. How do I achieve the abouve screenshot in my layout xml?
just play with margin to fit it exactly:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
>
<RelativeLayout
android:layout_width="130dip"
android:layout_height="130dip"
android:background="@drawable/bg" >
<com.example.mmlooloo.RoundedImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/imageView1"
android:layout_width="90dip"
android:layout_height="90dip"
android:layout_centerHorizontal="true"
android:layout_marginBottom="15dip"
android:layout_marginTop="10dip"
android:scaleType="centerCrop"
android:src="@drawable/profile"
app:border_color="#0000FF"
app:border_width="2dip"
app:corner_radius="80dip"
app:oval="true" />
</RelativeLayout>
</LinearLayout>
and:
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
</resources>
result: