Android Material Design之ShapeableImageView(十三)

  1. 效果图
    在这里插入图片描述
  2. 资源引入
implementation 'com.google.android.material:material:1.4.0'
  1. 属性
属性描述
android:id控件id
android:layout_width控件长度
android:layout_height控件高度
app:shapeAppearance控件外观样式
app:strokeWidth画笔粗度
app:strokeColor画笔颜色
android:src图像资源
  1. 源代码
    xml布局代码:
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout 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="match_parent">


    <com.google.android.material.imageview.ShapeableImageView
        android:id="@+id/shapeableImageView"
        android:layout_width="300dp"
        android:layout_height="300dp"
        android:layout_gravity="center"
        android:padding="2.5dp"
        android:src="@mipmap/ic_upic"
        app:shapeAppearance="@style/roundImg"
        app:strokeColor="@color/black"
        app:strokeWidth="5dp" />


    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/bottomNavMenu"
        android:layout_width="match_parent"
        android:layout_height="56dp"
        android:layout_gravity="bottom"
        app:itemIconSize="25dp"
        app:itemIconTint="@color/icon_color"
        app:itemTextColor="@color/text_color"
        app:labelVisibilityMode="labeled"
        app:menu="@menu/bottom_menu" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

style: roundImg.xml

 <style name="roundImg">
        <item name="cornerFamily">rounded</item>
        <item name="cornerSize">150dp</item>
    </style>
  1. 使用注意
    如果圆角图片需要加入边框线则需要设置android:padding 且padding的大小等于app:strokeWidth的一半,否则你将会看到上下左右 四个方向各有一段遮挡
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值