Skip to content

kongqw/ShapeView

Repository files navigation

ShapeView

How to

To get a Git project into your build:

Step 1. Add the JitPack repository to your build file

Add it in your root build.gradle at the end of repositories:

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

Step 2. Add the dependency

dependencies {
	implementation 'com.github.kongqw:ShapeView:1.1.5'
}

简介

该库旨在省去编写Shape文件,简洁、方便。

包含控件:

  • XButton(AppCompatButton)
  • XEditText(AppCompatEditText)
  • XImageButton(AppCompatImageButton)
  • XImageView(AppCompatImageView)
  • XTextView(AppCompatTextView)
  • XView(View)

包含布局:

  • XConstraintLayout(ConstraintLayout)
  • XFrameLayout(FrameLayout)
  • XLinearLayout(LinearLayout)
  • XRelativeLayout(RelativeLayout)

如果你要在这些控件上使用Shape图形,编写圆角、渐变色、Stroke、以及按下、不可用状态的样式,那么这个库可以更简洁方便的满足需求。

当然,这些控件和布局都是继承的原生控件和布局,你可以直接当做原生控件和布局进行使用。

包含自定义属性如下:

自定义属性 说明 类型 举例
isGrayMode 黑白模式 boolean app:isGrayMode="true"
cornerType 圆角 enum app:cornerType="top"
app:cornerType="left"
app:cornerType="right"
app:cornerType="bottom"
app:cornerType="rectangle"
app:cornerType="circle"
cornerRadius 圆角 dimension app:cornerRadius="10dp"
textColor 字体颜色 color app:textColor="#FFFF00"
textPressedColor 按下字体颜色 color app:textPressedColor="#ABCDEF"
textDisabledColor 不可用字体颜色 color app:textDisabledColor="#FF0000"
backgroundColorOrientation 背景渐变色方向 enum app:backgroundColorOrientation="horizontal"
app:backgroundColorOrientation="vertical"
backgroundColors 默认背景色 string app:backgroundColors="#987654,#00000000,#987654"
backgroundPressedColors 按下背景色 string app:backgroundPressedColors="#00000000,#987654"
backgroundDisabledColors 不可用背景色 string app:backgroundDisabledColors="#AAAAAA,#987654"
strokeWidth 默认Stroke宽度 dimension app:strokeWidth="3dp"
strokePressedWidth 按下Stroke宽度 dimension app:strokePressedWidth="10dp"
strokeDisabledWidth 不可用Stroke宽度 dimension app:strokeDisabledWidth="3dp"
strokeColor 默认Stroke颜色 color app:strokeColor="#000000"
strokePressedColor 按下Stroke颜色 color app:strokePressedColor="#FF00FF"
strokeDisabledColor 不可用Stroke颜色 color app:strokeDisabledColor="#00FF00"

全局黑白化

GrayMode.isGrayMode(applicationContext, true)

效果图:

ShapeButton.png

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages