博客
关于我
Android使用xml的shape自定义图形
阅读量:351 次
发布时间:2019-03-04

本文共 886 字,大约阅读时间需要 2 分钟。

android:shape=[“rectangle” | “oval” | “line” | “ring”]
shape的形状,默认为矩形,可以设置为矩形(rectangle)、椭圆形(oval)、线性形状(line)、环形(ring)

1.自定义纯色圆形
round.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"       android:shape="rectangle" >    <solid android:color="#283593"/>    <corners android:radius="50dp" /></shape>
//半径为50dp,颜色为#283593的圆形<ImageView    android:layout_width="50dp"    android:layout_height="50dp"    android:scaleType="center"    android:src="@drawable/manual_tuner_band_bg" />

2.自定义纯色矩形
rectangle.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"       android:shape="rectangle" >    <solid android:color="#283593"/>    <corners android:radius="50dp" /></shape>
//宽为30dp,高为50dp,颜色为#283593的矩形<ImageView    android:layout_width="30dp"    android:layout_height="50dp"    android:scaleType="center"    android:src="@drawable/manual_tuner_band_bg" />

转载地址:http://ysre.baihongyu.com/

你可能感兴趣的文章
Openlayers:DMS-DD坐标形式互相转换
查看>>
openlayers:圆孔相机根据卫星经度、纬度、高度、半径比例推算绘制地面的拍摄的区域
查看>>
OpenLDAP(2.4.3x)服务器搭建及配置说明
查看>>
OpenLDAP编译安装及配置
查看>>
Openmax IL (二)Android多媒体编解码Component
查看>>
OpenMCU(一):STM32F407 FreeRTOS移植
查看>>
OpenMCU(三):STM32F103 FreeRTOS移植
查看>>
OpenMCU(三):STM32F103 FreeRTOS移植
查看>>
OpenMCU(二):GD32E23xx FreeRTOS移植
查看>>
OpenMCU(五):STM32F103时钟树初始化分析
查看>>
OpenMCU(四):STM32F103启动汇编代码分析
查看>>
OpenMetadata 命令执行漏洞复现(CVE-2024-28255)
查看>>
OpenMMLab | AI玩家已上线!和InternLM解锁“谁是卧底”新玩法
查看>>
OpenMMLab | S4模型详解:应对长序列建模的有效方法
查看>>
OpenMMLab | 【全网首发】Llama 3 微调项目实践与教程(XTuner 版)
查看>>
OpenMMLab | 不是吧?这么好用的开源标注工具,竟然还有人不知道…
查看>>