Skip to content

Instantly share code, notes, and snippets.

View bkurzius's full-sized avatar

Brian Kurzius bkurzius

  • A&E Television Networks | Studio Classics
  • New York | North Carolina
View GitHub Profile
@bkurzius
bkurzius / gist:a4d165683a57742ad4c9
Created April 17, 2015 21:16
Android ScrollView -- fade a view in or out depending on the vertical scroll postion
mScrollView.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
@Override
public void onScrollChanged() {
// the scrollposition that the fade will start
int mScrollThreshold = 100;
// how fast the view will fade with the scroll -- use multiples of 10
int mScrollVariance = 40;
int scrollY = mScrollView.getScrollY();
// if the difference between the scrollthreshold is +/-mScrollVariance, show the view accordingly
float newAlpha = 0;
@bkurzius
bkurzius / gist:11d7825138c0a20da0d5
Created April 16, 2015 18:41
android listener when a layout draws
mProgressBar.getViewTreeObserver()
.addOnGlobalLayoutListener(
new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
//... do code here
}
});
@bkurzius
bkurzius / gist:bc77bda168b1b3ab08e3
Last active August 29, 2015 14:19
Android Custom Dialog
final Dialog dialog = new Dialog(this);
// remove the title
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
// set the layout
dialog.setContentView(R.layout.dialog_series_info);
// do whatever you need to with the data
TextView title = (TextView)dialog.findViewById(R.id.series_title);
title.setText(mSeriesTitle);
dialog.show();
@bkurzius
bkurzius / CircularNetworkImageView
Last active September 21, 2020 16:18
Circular NetworkImageView for use with Volley. Creates a circular bitmap and uses whichever dimension is smaller to determine the radius. Also constrains the circle to the leftmost part of that image. Used in the same way as the Volley NetworkImageView, in both code and xml. Of course you'll need to include the Volley Library in you app too.
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Bitmap.Config;
import android.graphics.PorterDuff.Mode;
import android.graphics.drawable.BitmapDrawable;