android 图片边框


首先想到用自定义imageview


在产品列表中显示不出来,貌似只能在
单ImageView的布局里才可以,如果是
myImageView嵌入到某父布局里,就会显示不出来


然后再gridview里也存在问题了,
在产品图片不规整的情况下,对特别小的图片 边框会缩小很多


后来使用了另一种方案


首先自定义xml drawable
<shape xmlns:android="http://schemas.android.com/apk/res/android" >


    <solid android:color="#ffffff" />


   <stroke
        android:width="1dp"
        android:color="#a4a4a4" />


    <padding
        android:bottom="1dp"
        android:left="1dp"
        android:right="1dp"
        android:top="1dp" />


</shape>


然后再
  <ImageView
        android:id="@+id/productlist_item_img"
        android:layout_width="80dp"
        android:layout_height="60dp"
        android:layout_alignLeft="@id/item_name"
        android:layout_below="@id/tem_name"
        android:layout_marginTop="4dp"
         android:layout_marginBottom="4dp"  
         android:padding="1dp"
        android:background="@drawable/product_list_img_border"/>
加入了android:padding="1dp"
        android:background="@drawable/product_list_img_border这2句





<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="2dp"
    android:background="@drawable/product_list_img_border"
    android:padding="1dp" >


    <ImageView
        android:id="@+id/picshow_item_img"
        android:layout_width="wrap_content"
        android:layout_height="110dp"
        android:layout_centerInParent="true"
        android:layout_marginTop="2dp"
        android:scaleType="centerCrop"
        android:src="@drawable/placeholder" />


</RelativeLayout>
加入了android:padding="1dp"
        android:background="@drawable/product_list_img_border这2句
其实不佳padding也可以
  
通过定义imageview的背景,并设置padding实现边框


对自定义属性还是不够熟悉

转载于:https://my.oschina.net/u/199733/blog/108124

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值