Source: Self
Question: How to add ripple effect with xml instead of using RippleDrawable
?
Answer:
test_layout.xml
:
<?xml version="1.0" encoding="utf-8"?>
import android.support.annotation.NonNull; | |
import android.support.v4.app.Fragment; | |
import android.support.v4.app.FragmentManager; | |
/** | |
* Set of methods that help with fragment manipulation. | |
*/ | |
public class FragmentUtils { |
import android.annotation.SuppressLint | |
import android.app.Activity | |
import android.app.AlertDialog | |
import android.content.Context | |
import android.support.annotation.StringRes | |
import android.support.v4.app.Fragment | |
import android.view.LayoutInflater | |
import android.view.View | |
import android.widget.Button | |
import android.widget.TextView |
inline fun SharedPreferences.edit(changes: SharedPreferences.Editor.() -> SharedPreferences.Editor) { | |
edit().changes().apply() | |
} | |
fun ImageView.tintSrc(@ColorRes colorRes: Int) { | |
val drawable = DrawableCompat.wrap(drawable) | |
DrawableCompat.setTint(drawable, ContextCompat.getColor(context, colorRes)) | |
setImageDrawable(drawable) | |
if (drawable is TintAwareDrawable) invalidate() // Because in this case setImageDrawable will not call invalidate() | |
} |
/** Set the View visibility to VISIBLE and eventually animate the View alpha till 100% */ | |
fun View.visible(animate: Boolean = true) { | |
if (animate) { | |
animate().alpha(1f).setDuration(300).setListener(object : AnimatorListenerAdapter() { | |
override fun onAnimationStart(animation: Animator) { | |
super.onAnimationStart(animation) | |
visibility = View.VISIBLE | |
} | |
}) | |
} else { |
fun View.visible() { | |
visibility = View.VISIBLE | |
} | |
fun View.invisible() { | |
visibility = View.INVISIBLE | |
} | |
fun View.gone() { | |
visibility = View.GONE |
import android.support.v7.widget.RecyclerView; | |
import android.util.SparseArray; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import java.util.ArrayList; | |
import java.util.List; | |
/** | |
* Created by Mehedi on 5/31/15. | |
* |
package com.liberorignanese.android.gist; | |
import android.graphics.Canvas; | |
import android.graphics.Paint; | |
import android.text.style.ReplacementSpan; | |
/** | |
* Created by Libero Rignanese. | |
*/ |
apply plugin: 'com.android.application' | |
apply plugin: 'android-apt' | |
android { | |
compileSdkVersion versions.compileSdk | |
buildToolsVersion versions.buildTools | |
defaultConfig { | |
applicationId "samples.linhtruong.com.ui_reactive_rxjava_realm" | |
minSdkVersion versions.minSdk |
#!/usr/bin/groovy | |
/* | |
* Copyright (c) 2016, Andrey Makeev <[email protected]> | |
* All rights reserved. | |
* | |
* Redistribution and use in source and binary forms, with or without | |
* modification, are permitted provided that the following conditions | |
* are met: | |
* 1. Redistributions of source code must retain the above copyright |
Source: Self
Question: How to add ripple effect with xml instead of using RippleDrawable
?
Answer:
test_layout.xml
:
<?xml version="1.0" encoding="utf-8"?>