Skip to content

Instantly share code, notes, and snippets.

relex ongakuer

Block or report user

Report or block ongakuer

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
ongakuer /
Created Sep 12, 2016
Show PopupWindow in Immersive Sticky mode
public class MainActivity extends AppCompatActivity {
private PopupWindow mPopupWindow;
@Override protected void onCreate(Bundle savedInstanceState) {
int windowWidth = 480;
int windowHeight = 120;
ongakuer /
Last active Jan 16, 2019
Smooth LinearGradient
public class MathUtil {
public static float constrain(float min, float max, float v) {
return Math.max(min, Math.min(max, v));
public static float interpolate(float x1, float x2, float f) {
return x1 + (x2 - x1) * f;
public static float uninterpolate(float x1, float x2, float v) {
ongakuer /
Last active Aug 29, 2015
import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.ViewGroup;
import com.makeramen.RoundedImageView;
public class NetworkRoundedImageView extends RoundedImageView {
ongakuer / gist:add32475478360251809
Created Jul 7, 2014
SquareFrameLayout (这个版本的测量考虑更全面)
View gist:add32475478360251809
* 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
* Unless required by applicable law or agreed to in writing, software
ongakuer / gist:b531b3de0d389463e1fe
Last active Aug 29, 2015
View gist:b531b3de0d389463e1fe
private void parseJson() {
String json = "{\"school\":{\"classes\": [{\"name\":\"one\",\"count\":1},{\"name\":\"two\",\"count\":2}],\"headMaster\" : \"Einstein\"}}";
ObjectMapper mapper = new ObjectMapper();
try {
ResponseModle response = mapper.readValue(json, ResponseModle.class);
Log.e(this.getClass().getName(), "headMaster : " + response.getSchool().getHeadMaster());
ongakuer / gist:0ef96ebc7e89288590fd
Last active Mar 14, 2018
Android 测量字符宽度的几种方法和场景
View gist:0ef96ebc7e89288590fd
mTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
TextPaint textPaint = mTextView.getPaint();
String source = "Lorem ipsum dolor sit amet";
// mTextView的宽度作为参考值
mTextView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
public void onGlobalLayout() {
int textViewWidth = mTextView.getMeasuredWidth();
You can’t perform that action at this time.