how to make imageview border with two color and fix size border width in andorid

十年热恋 提交于 2019-12-08 04:13:35

问题


I have create the circularimageview and this image view set the two colors and this color sizw are same how to set border with fix size and two borders?

**I have already use library 'com.pkmmte.view:circularimageview:1.1' **


#ce90ce inner circle
# ab84ab outer circle
ineer circle opacity 20%
outer circle opacity 15%

My Image like this

My Adapter Layout

<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="wrap_content"
android:background="@color/Background_Main"
android:orientation="horizontal">

<com.pkmmte.view.CircularImageView
    android:id="@+id/ivPerson"
    android:layout_width="77dp"
    android:layout_height="77dp"
    android:layout_marginLeft="10dp"
    android:layout_marginTop="10dp"
    app:border="true"
    app:border_color="#ab84ab"
    app:border_width="10dp"
    app:shadow="true" />

<TextView
    android:id="@+id/tvPersonName"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toRightOf="@+id/ivPerson"
    android:paddingLeft="10dp"
    android:paddingTop="30dp"
    android:textAlignment="viewStart"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:textColor="@color/tapon"
    android:textSize="20sp" />

<Button
    android:id="@+id/addbn"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_marginRight="20dp"
    android:layout_marginTop="25dp"
    android:background="@drawable/buildlis_category_btn_selected"
    android:focusable="false"
    android:minHeight="0dp"
    android:minWidth="0dp" />


回答1:


here is xml code and easy to maintain :

double_circle_image.xml

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>

        <shape android:shape="oval">

            <stroke
                android:width="10dp"
                android:color="#0000ff" />
        </shape>
    </item>

    <item
        android:bottom="10dp"
        android:left="10dp"
        android:right="10dp"
        android:top="10dp">

        <shape android:shape="oval">

            <stroke
                android:width="10dp"
                android:color="#ff0000" />
        </shape>
    </item>
    <item
        android:drawable="@drawable/ic_launcher"
        android:bottom="20dp"
        android:left="20dp"
        android:right="20dp"
        android:top="20dp"/>
</layer-list>



回答2:


Use this library to shape the image to circle. You add your image using tag, right? Then, add a background (shaded) (Vector) from drawable as well. It will enable to make the look like you wanted.

You should use vector file as your images as well. This is cool library to convert svg images to vector images. If you do so, your images will look like as your wished in the question, in any devices!

Hope it helps. Cheers!



来源:https://stackoverflow.com/questions/39830754/how-to-make-imageview-border-with-two-color-and-fix-size-border-width-in-andorid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!