如何使用两种颜色制作imageview边框并在andorid中修复尺寸边框宽度 [英] how to make imageview border with two color and fix size border width in andorid

查看:177
本文介绍了如何使用两种颜色制作imageview边框并在andorid中修复尺寸边框宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了circularimageview并且这个图像视图设置了两种颜色,这个颜色sizw是如何设置边框的固定大小和两个边框相同?

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?

**我已经使用了库'com.pkmmte.view:circularimageview:1.1'**

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


#ce90ce inner circle

#ab84ab outer circle

ineer circle opacity 20%

外圈不透明度15%


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

我这样的图像

我的适配器布局

<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" />

推荐答案

这里是xml代码,易于维护:

here is xml code and easy to maintain :

double_circle_image.xml

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>

这篇关于如何使用两种颜色制作imageview边框并在andorid中修复尺寸边框宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆