Skip to content

Instantly share code, notes, and snippets.


Yang Hui kyze8439690

Block or report user

Report or block kyze8439690

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
kyze8439690 / styles.xml
Last active Dec 27, 2015
In order to make a holo style scrollbar in android 2.3,first you have to import the holo scrollbar resource(sdk/platforms/android-18/data/res/drawable-xhdpi/scrollbar_handle_holo_light.9.png) into your drawable dir, and then to change your style xml
View styles.xml
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:scrollbarSize">10.0dip</item><!--very important, in order to show scrollbar properly in android 2.3 and before-->
<item name="android:scrollbarThumbVertical">@drawable/scrollbar</item>
<item name="android:scrollbarThumbHorizontal">@drawable/scrollbar</item>
<item name="android:scrollbarTrackVertical">@null</item>
<item name="android:scrollbarTrackHorizontal">@null</item>
kyze8439690 /
Created Nov 2, 2013
set ListView divider drawable and height programmatically,must setDivider(Drawble) fiist, and then setDividerHeight, otherwise, the dividerheight will be 0.
getListView().setDivider(getResources().getDrawable(R.color.list_background)); //must be called first
public class Singleton {
private static Object obj = new Object();
private static Singleton instance = null;
private Singleton(){
public static Singleton getInstance() {
// if already inited, no need to get lock everytime
kyze8439690 /
Created Nov 11, 2013
fix android 2.3 can't decode bitmap in rgba8888 format
public static Bitmap convert(Bitmap bitmap, Bitmap.Config config) {
Bitmap convertedBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), config);
Canvas canvas = new Canvas(convertedBitmap);
Paint paint = new Paint();
canvas.drawBitmap(bitmap, 0, 0, paint);
return convertedBitmap;
kyze8439690 /
Created Nov 22, 2013
ListView do not show header view until you add an adapter to it
//add adapter and show the header
public class ExpandedGridView extends GridView{
public ExpandedGridView(Context context) {
public ExpandedGridView(Context context, AttributeSet attrs) {
super(context, attrs);
public ExpandedGridView(Context context, AttributeSet attrs, int defStyle) {
kyze8439690 / build.gradle
Last active Jan 19, 2017
Use build.gradle to compile all jars in libs folder and ndk support
View build.gradle
//compile all jar in libs folder
dependencies {
compile fileTree(dir: 'libs' , include: '*.jar')
//pack all so file into a jar and compile it
task nativeLibsToJar(
type: Zip,
description: 'create a jar archive of the native libs') {
destinationDir file('./libs')
baseName 'native-libs'
kyze8439690 /
Created Nov 30, 2013
A custom RelativeLayout which will auto match its height to its width
public class SquareRelativeLayout extends RelativeLayout{
public SquareRelativeLayout(Context context) {
public SquareRelativeLayout(Context context, AttributeSet attrs) {
super(context, attrs);
public SquareRelativeLayout(Context context, AttributeSet attrs, int defStyle) {
kyze8439690 /
Created Dec 26, 2013
OnScrollListener to detect scrollup and scrolldown in ListView.
public class ListViewOnScrollListener extends OnScrollListener{
public void onScrollStateChanged(AbsListView view, int scrollState) {}
private int lastVisibleItem = 0;
private int lastY = 0;
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
int top = 0;
View proguard-rules.txt
-optimizationpasses 5
# 混淆时不会产生形形色色的类名
# 指定不去忽略非公共的类库
# 不预校验
You can’t perform that action at this time.