Skip to content

Instantly share code, notes, and snippets.

View GregSaintJean's full-sized avatar
🎯
Focusing

Gregory Saint-Jean GregSaintJean

🎯
Focusing
View GitHub Profile
@GregSaintJean
GregSaintJean / DpToPxAndPxToDp
Created April 28, 2016 19:23 — forked from laaptu/DpToPxAndPxToDp
Android convert dp to px and vice versa
public static float convertPixelsToDp(float px){
DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics();
float dp = px / (metrics.densityDpi / 160f);
return Math.round(dp);
}
public static float convertDpToPixel(float dp){
DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics();
float px = dp * (metrics.densityDpi / 160f);
return Math.round(px);
@GregSaintJean
GregSaintJean / DividerItemDecoration.java
Created January 4, 2016 01:15 — forked from alexfu/DividerItemDecoration.java
An ItemDecoration that draws dividers between items. Pulled from Android support demos.
/*
* Copyright (C) 2014 The Android Open Source Project
*
* 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
about
account
add
admin
api
app
apps
archive
archives
auth