All Projects → akndmr → ColorPrefUtil

akndmr / ColorPrefUtil

Licence: MIT License
ColorPrefUtil for Android. Easily change theme and view/layout/text colors or custom background drawables.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to ColorPrefUtil

react-native-dual
ScrollView, FlatList, SectionList and ListView with dual background
Stars: ✭ 28 (-49.09%)
Mutual labels:  color
color-description
Color-Description turns a technical color representation into a human readable description.
Stars: ✭ 18 (-67.27%)
Mutual labels:  color
dynamic-utils
Utility functions to perform dynamic operations on Android.
Stars: ✭ 86 (+56.36%)
Mutual labels:  color
a-color-picker
A color picker for web app
Stars: ✭ 97 (+76.36%)
Mutual labels:  color
luxpy
Python toolbox for lighting and color science
Stars: ✭ 55 (+0%)
Mutual labels:  color
DDHTweaks
Tweak UI elements at run time to find the perfect values
Stars: ✭ 27 (-50.91%)
Mutual labels:  color
ghci-color
colorize ghci output
Stars: ✭ 74 (+34.55%)
Mutual labels:  color
php-invert-color
Invert a given color.
Stars: ✭ 13 (-76.36%)
Mutual labels:  color
elm-color-extra
🎨 Additional color handling for Elm
Stars: ✭ 28 (-49.09%)
Mutual labels:  color
nord-mintty
An arctic, north-bluish clean and elegant Mintty color theme.
Stars: ✭ 40 (-27.27%)
Mutual labels:  color
NamedColors.jl
More color names than you ever knew you wanted
Stars: ✭ 24 (-56.36%)
Mutual labels:  color
ColorPick.js
A simple and minimal jQuery color picker plugin for the modern web.
Stars: ✭ 48 (-12.73%)
Mutual labels:  color
MNIST-invert-color
Invert the color of MNIST images with PyTorch
Stars: ✭ 13 (-76.36%)
Mutual labels:  color
unblending
Decomposing an input image into layers via "color unblending"
Stars: ✭ 125 (+127.27%)
Mutual labels:  color
color-rgba
Get rgba array from color string
Stars: ✭ 18 (-67.27%)
Mutual labels:  color
colorsys.rs
Lib for modifying colors and converting to other spaces
Stars: ✭ 28 (-49.09%)
Mutual labels:  color
LycricsTextView
No description or website provided.
Stars: ✭ 14 (-74.55%)
Mutual labels:  color
UnityColorPicker
A standalone color picker asset for Unity
Stars: ✭ 70 (+27.27%)
Mutual labels:  color
word-color
Finds colors associated with a word, basically https://picular.co/
Stars: ✭ 39 (-29.09%)
Mutual labels:  color
Nova-Dark-Theme
A dark theme for Laravel Nova
Stars: ✭ 72 (+30.91%)
Mutual labels:  color

ColorPrefUtil


ColorPrefUtil for Android
Easily change theme & background or text colors of views&layouts. [API >= 19]

Release Android Arsenal



Sample Preview:

ColorPrefUtil sample gif


Setup

Gradle

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.akndmr:ColorPrefUtil:1.0.1'
	}

Usage

For a complete sample, check app folder.

Changing Theme

First, you need to set different styles for different color themes - if you want to change theme(setTheme(R.style.id)).

styles.xml

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">  
    <!-- Customize your theme here. -->  
    <item name="colorPrimary">@color/colorPrimary</item>  
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>  
    <item name="colorAccent">@color/colorAccent</item>  
</style>  
  
<style name="AppThemePurple" parent="Theme.AppCompat.Light.DarkActionBar">  
    <item name="colorPrimary">@color/colorPrimaryPurple</item>  
    <item name="colorPrimaryDark">@color/colorPrimaryDarkPurple</item>  
    <item name="colorAccent">@color/colorAccentPurple</item>  
</style>

MainActivity.java

@Override  
protected void onCreate(Bundle savedInstanceState) {  
    super.onCreate(savedInstanceState);  
  
    // Set theme before setContentView  
    mSharedPreferences = getSharedPreferences(PREF_COLOR, MODE_PRIVATE);  
    int themeSelected = mSharedPreferences.getInt(THEME_SELECTED, R.style.AppTheme);  
    ColorPrefUtil.changeThemeStyle(this, themeSelected);  
  
    setContentView(R.layout.activity_main);  
  
//...  
}  

Changing BackgroundColor of Single View and All Views

MainActivity.java

int selectedBackgroundColorId;

@Override  
protected void onCreate(Bundle savedInstanceState) {  
    super.onCreate(savedInstanceState);  

// Get selected colorId from preferences, if null, use default background color(colorPrimary)
selectedBackgroundColorId = mSharedPreferences.getInt(COLOR_SELECTED, R.color.colorPrimary);

// Single view  
mButton = findViewById(R.id.button);  
ColorPrefUtil.changeBackgroundColorOfSingleView(this, mButton, selectedBackgroundColorId);  
  
// All views inside parent layout
mConstraintLayout = findViewById(R.id.cl_container);
ColorPrefUtil.changeBackgroundColorOfChildViews(this, mConstraintLayout, selectedBackgroundColorId);  
}

Changing Text Color of Single View and All Views

// All views inside given parent layout
  ColorPrefUtil.changeTextColorOfChildViews(this, mConstraintLayout, textColorId, hintColorId);  
 
 // Single view
  ColorPrefUtil.changeTextColorOfSingleView(this, mTextView, textColorId, hintColorId);

Changing Tint Color of Icons (ImageView)

ColorPrefUtil.changeTintColorOfIcon(this, mImageViewIcon, iconTintColorId);

Changing Background Drawable of Single View and All Views You can set custom background drawables for views.

ColorPrefUtil.changeBackgroundDrawableOfChildViews(this, mConstraintLayout, backgroundColorId);  
ColorPrefUtil.changeBackgroundDrawableOfSingleView(this, mButton, backgroundDrawableId);

Changing Item Colors of NavigationView Change icon tint color and text colors of Nav view.

ColorPrefUtil.changeColorOfItemsOfNavView(mNavigationView, iconColorId, textColorId);

Changing Colors of TabLayout Change TabLayout background, selected tab, indicator, text colors.

ColorPrefUtil.changeColorOfTabLayout(this, mTabLayout, backgroundColorId, selectedTabColorId, indicatorColorId, textColorId);


**LICENSE**

MIT License

Copyright (c) 2019 Akın Demir

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

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