草庐IT

是时候丢掉项目里Shape XML文件了

项目里的shape.xmlselector.xmllayer_list.xml文件太多啦想个办法替代吧:1.shape.xml的替代法旧写法-shape.xml新写法-kotlintextView.background=shape{shape=RECTANGLEsolid{color=Color.parseColor("#f00000")}corners{radius=15f.dp}}xml里所有的属性都支持2.selector.xml的替代法旧写法-selector.xmlnormal.xmlpressed.xmlselector.xml新写法-kotlintextView.backgrou

Android MaterialButton使用详解,告别shape、selector

效果前言先来看一下​​MaterialButton​​​是什么由上图可以看到​​​MaterialButton​​​也没有什么神秘的,不过是Button的一个子类而已,但是经过谷歌的封装之后,在符合​​MaterialDesign​​的基础上,使用起来更加方便了,且容易实现预期效果。使用引入material包implementation'com.google.android.material:material:1.2.1'常规android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="

Android MaterialButton使用详解,告别shape、selector

效果前言先来看一下​​MaterialButton​​​是什么由上图可以看到​​​MaterialButton​​​也没有什么神秘的,不过是Button的一个子类而已,但是经过谷歌的封装之后,在符合​​MaterialDesign​​的基础上,使用起来更加方便了,且容易实现预期效果。使用引入material包implementation'com.google.android.material:material:1.2.1'常规android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="

Android ShapeableImageView使用详解,告别shape、三方库

效果前言先来看一下​​ShapeableImageView​​​是什么由上图可以看到​​​ShapeableImageView​​​也没有什么神秘的,不过是​​ImageView​​​的一个子类而已,但是从效果图来看,在​​不写shape、不引入三方库​​的情况下,还是挺容易实现预期效果的,而且扩展性良好。使用引入material包implementation'com.google.android.material:material:1.2.1'常规android:layout_width="wrap_content"android:layout_height="wrap_content"an

Android ShapeableImageView使用详解,告别shape、三方库

效果前言先来看一下​​ShapeableImageView​​​是什么由上图可以看到​​​ShapeableImageView​​​也没有什么神秘的,不过是​​ImageView​​​的一个子类而已,但是从效果图来看,在​​不写shape、不引入三方库​​的情况下,还是挺容易实现预期效果的,而且扩展性良好。使用引入material包implementation'com.google.android.material:material:1.2.1'常规android:layout_width="wrap_content"android:layout_height="wrap_content"an