maoruibin/OneDrawable
소개
:pencil2: Use only one image to set a background with a click effect for the View
디자인 및 미디어측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalOneDrawable

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.
shot

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
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.
관련 프로젝트 살펴보기
불러오는 중…