Skip to content

Instantly share code, notes, and snippets.

View johnybot's full-sized avatar

Johnathan Harms johnybot

  • Vancouver, B.C.
View GitHub Profile
@johnybot
johnybot / TintableImageView.java
Created March 9, 2015 21:41
TintableImageView
public class TintableImageView extends ImageView {
private ColorStateList tint;
public TintableImageView(Context context) {
super(context);
}
public TintableImageView(Context context, AttributeSet attrs) {
super(context, attrs);
@johnybot
johnybot / color_filter.java
Created March 9, 2015 21:40
Color Filter
iconView.setColorFilter(getResources().getColor(R.color.primary_dark));
@johnybot
johnybot / color_state_text.xml
Created March 9, 2015 21:39
ColorStateList textview
<TextView
android:id="@+id/menu_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/Text.Title"
android:textColor="@color/menu_selector" />
@johnybot
johnybot / button_color.xml
Created March 9, 2015 21:38
Color State List
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/primary_dark" android:state_activated="true" />
<item android:color="@color/primary_text" />
</selector>
@johnybot
johnybot / DestructiveDialog.java
Created March 9, 2015 21:38
Destructive Dialog
AlertDialog alertDialog = new AlertDialog.Builder(
getActivity(),
R.style.AlertDialogCustom_Destructive)
.setPositiveButton(R.string.button_delete, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
// Delete Action
}
})
.setNegativeButton(R.string.button_cancel, new DialogInterface.OnClickListener() {
@johnybot
johnybot / styles.xml
Created March 9, 2015 21:37
Destructive styles.xml
<style name="AlertDialogCustom.Destructive">
<item name="android:buttonBarPositiveButtonStyle">@style/DestructiveButton</item>
</style>
<style name="DestructiveButton"
parent="android:Widget.DeviceDefault.Button.Borderless">
<item name="android:textColor">@color/red</item>
</style>
@johnybot
johnybot / themes.xml
Created March 9, 2015 21:37
Dialog themes.xml
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="colorAccent">@color/accent</item>
<item name="android:alertDialogTheme">@style/AlertDialogCustom</item>
</style>
@johnybot
johnybot / styles.xml
Created March 9, 2015 21:36
Dialog styles.xml
<style name="AlertDialogCustom" parent="Theme.AppCompat.Light.Dialog">
<item name="colorAccent">@color/primary</item>
</style>
@johnybot
johnybot / RippleResource
Created March 9, 2015 21:36
RippleResource
int[] attrs = new int[]{R.attr.selectableItemBackground};
TypedArray typedArray = getActivity().obtainStyledAttributes(attrs);
int backgroundResource = typedArray.getResourceId(0, 0);
view.setBackgroundResource(backgroundResource);
@johnybot
johnybot / selectableItemBackground
Created March 9, 2015 21:35
selectableItemBackground
<View
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground" />