Skip to content

Instantly share code, notes, and snippets.

View kolanse's full-sized avatar

Samuel Ochuba kolanse

View GitHub Profile
@kolanse
kolanse / activity_main.xml
Created August 8, 2020 19:49
Dark mode xml file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background_lay"
tools:context=".MainActivity">
<Button
@kolanse
kolanse / button_design.xml
Created August 8, 2020 19:53
button design
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<solid android:color="@color/buttonbackground"/>
<corners android:radius="16dp"/>
</shape>
</item>
</selector>
@kolanse
kolanse / colors.xml
Created August 8, 2020 19:54
colors
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#6200EE</color>
<color name="colorPrimaryDark">#3700B3</color>
<color name="colorAccent">#03DAC5</color>
<color name="background_lay">#fff</color>
<color name="buttonbackground">#00008B</color>
<color name="button_text">#fff</color>
<string name="mode">Enable Dark Mode</string>
@kolanse
kolanse / colors.xml
Created August 8, 2020 20:17
color night
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#6200EE</color>
<color name="colorPrimaryDark">#3700B3</color>
<color name="colorAccent">#03DAC5</color>
<color name="background_lay">#00008B</color>
<color name="buttonbackground">#fff</color>
<color name="button_text">#00008B</color>
</resources>
@kolanse
kolanse / MainActivity.kt
Created August 8, 2020 20:23
dark mode kotlin
package com.example.constrainttutorial
import android.content.SharedPreferences
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Button
import androidx.appcompat.app.AppCompatDelegate
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
<style name="spinnerTheme" parent= "Widget.MaterialComponents.TextInputLayout.FilledBox.ExposedDropdownMenu">
<item name="strokeColor">@color/grey</item>
</style>
<style name="spinnerTheme" parent= "Widget.MaterialComponents.TextInputLayout.FilledBox.ExposedDropdownMenu">
<item name="strokeColor">@color/grey</item>
<item name="endIconDrawable">@drawable/vector__spinner_dropdown</item>
</style>
@kolanse
kolanse / IconView.kt
Created November 23, 2020 10:10 — forked from nickbutcher/IconView.kt
A prototype implementation of a shadow effect inspired by the Google Play Games app (https://play.google.com/store/apps/details?id=com.google.android.play.games).
/*
* Copyright 2017 Google Inc.
*
* 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
var myEditText = findViewById<EditText>(R.id.myEditText)
myEditText.doOnTextChanged { text, start, before, count ->
run {
// run your code here.
// the text is the changed text
}