All Projects → maoruibin → Onedrawable

maoruibin / Onedrawable

Licence: apache-2.0
✏️ Use only one image to set a background with a click effect for the View

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Onedrawable

android-multibackground
This library can easily apply round corner、stroke、shadow and different state effects to background drawable.
Stars: ✭ 18 (-93.96%)
Mutual labels:  background, drawable
Editdrawabletext
EditDrawableText - An EditText which makes your Drawable Clickable
Stars: ✭ 288 (-3.36%)
Mutual labels:  drawable
lovelace-animated-background
Animated backgrounds for lovelace
Stars: ✭ 123 (-58.72%)
Mutual labels:  background
Govern
Component-based state management for JavaScript.
Stars: ✭ 270 (-9.4%)
Mutual labels:  state
Uilibrary
平时项目开发中写的自定义Drawable、View和Shape
Stars: ✭ 260 (-12.75%)
Mutual labels:  drawable
Backgroundlibrary
A framework for directly generating shape through Tags, no need to write shape.xml again(通过标签直接生成shape,无需再写shape.xml)
Stars: ✭ 3,179 (+966.78%)
Mutual labels:  drawable
django-select2
This is a Django integration for Select2
Stars: ✭ 73 (-75.5%)
Mutual labels:  select
Selectr
A lightweight, vanilla javascript select box replacement. No dependencies.
Stars: ✭ 293 (-1.68%)
Mutual labels:  select
React Native Calendar Select
A component to select period from calendar like Airbnb
Stars: ✭ 279 (-6.38%)
Mutual labels:  select
Uieffect
UIEffect is an effect component for uGUI element in Unity. Let's decorate your UI with effects!
Stars: ✭ 3,449 (+1057.38%)
Mutual labels:  background
React Loads
React Loads is a backend agnostic library to help with external data fetching & caching in your UI components.
Stars: ✭ 268 (-10.07%)
Mutual labels:  state
Ngx Drag To Select
A lightweight, fast, configurable and reactive drag-to-select component for Angular 6 and beyond
Stars: ✭ 262 (-12.08%)
Mutual labels:  select
Redux Orm
A small, simple and immutable ORM to manage relational data in your Redux store.
Stars: ✭ 2,922 (+880.54%)
Mutual labels:  state
Material Ui Superselectfield
multiselection autocomplete dropdown component for Material-UI
Stars: ✭ 260 (-12.75%)
Mutual labels:  select
Ng Select
Select component for angular
Stars: ✭ 291 (-2.35%)
Mutual labels:  select
ScxmlEditor-Tutorial
ScxmlEditor - powerful tool for creating, editing and debugging scxml files
Stars: ✭ 33 (-88.93%)
Mutual labels:  state
Unistore
🌶 350b / 650b state container with component actions for Preact & React
Stars: ✭ 2,850 (+856.38%)
Mutual labels:  state
React Recomponent
🥫 Reason-style reducer components for React using ES6 classes.
Stars: ✭ 272 (-8.72%)
Mutual labels:  state
Effector
The state manager ☄️
Stars: ✭ 3,572 (+1098.66%)
Mutual labels:  state
Spedittool
An efficient and scalable library for inputing and displaying gif or @mention on graph-text mixed TextView/EditText
Stars: ✭ 292 (-2.01%)
Mutual labels:  drawable

OneDrawable

Build Status

OneDrawable

Only use one drawable/color resource to set the background of the View. | OneDrawable - 仅使用一张资源图片为 View 设置具有按下效果的背景

Sample

Please see the sample app for a library usage example.

sample apk

shot

demo

Gradle

dependencies {
    compile 'name.gudong:one-drawable:1.1.1'
}

Usage

common usage

Drawable drawable = OneDrawable.createBgDrawable(this,R.drawable.ic_action_name);
tvIcon1.setBackgroundDrawable(drawable);

common api

  • createBgDrawable (use drawable resource create a background)
  • createBgColor (use color resource create a background)

indicate pressed mode

pressed state with dark mode. In this mode, drawable will automatically cover a layer of dark when pressed.

drawable background

Drawable icon1 = OneDrawable.createBgDrawableWithDarkMode(this,R.drawable.ic_action_name);
tvIcon1.setBackgroundDrawable(icon1);

color background

Drawable color2 = OneDrawable.createBgColor(this,R.color.colorAccent);
tvColor2.setBackgroundDrawable(color2);

pressed state with alpha mode. In this mode, drawable will automatically change alpha value to 0.7 when pressed.

Drawable icon3 = OneDrawable.createBgDrawableWithAlphaMode(this,R.drawable.ic_action_add);
tvIcon3.setBackgroundDrawable(icon3);

Custom Alpha value

Sometimes, maybe you need custom alpha value, you can use methods like follows.

Drawable icon2 = OneDrawable.createBgDrawableWithDarkMode(this,R.drawable.ic_action_add,0.4f);
tvIcon2.setBackgroundDrawable(icon2);

Drawable icon4 = OneDrawable.createBgColorWithAlphaMode(this,R.drawable.ic_action_name,0.3f);
tvIcon4.setBackgroundDrawable(icon4);

Drawable icon4 = OneDrawable.createBgColorWithDarkMode(this,R.color.colorAccent,0.3f);
tvIcon4.setBackgroundDrawable(icon4);


Drawable icon4 = OneDrawable.createBgColorWithAlphaMode(this,R.color.colorAccent,0.3f);
tvIcon4.setBackgroundDrawable(icon4);

Note: Because of only clickable view show it's pressed drawable, so you should set view clickable as true before you want to watch pressed effect.

Author

http://gudong.name

https://github.com/maoruibin

http://weibo.com/maoruibin

License

Copyright 2017 GuDong

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].