Skip to content

Instantly share code, notes, and snippets.

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/notice_item_tv_time"
android:layout_alignBottom="@id/notice_item_fl_avatar"
android:layout_toRightOf="@id/notice_item_fl_avatar"
android:orientation="horizontal" >
<Button
public class CameraPictureUtil {
private static final String TAG = "CameraPictureUtil";
public static final int RESULTCODE_IMAGE_LOCATION = 100, RESULT_FILE_LOCATION = 102,
RESULTCODE_IMAGE_CAMERA = 101;
// 获取相机拍摄图片
public static String cameraImage(Activity activity) {
if (!LocalFileUtil.checkSdCardMount(activity)) {
return null;
}
@ixiyang
ixiyang / gist:88666435c474dcf3ac5f
Created September 12, 2014 06:21
Configuration is useful
// stop landscape on QVGA/HVGA
int screenSize = getResources().getConfiguration().screenLayout
& Configuration.SCREENLAYOUT_SIZE_MASK;
if (screenSize == Configuration.SCREENLAYOUT_SIZE_SMALL) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
@ixiyang
ixiyang / DiscoverLayout.java
Last active August 29, 2015 14:05
When the listview is scrolled to bottom,you can still scroll up to show the discoverview.
package com.discoverlistview.xy.discoverlistview;
import android.content.Context;
import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.animation.AccelerateInterpolator;
@ixiyang
ixiyang / canChildScrollUp
Created August 14, 2014 06:53
from SwipRefreshLayout
/**
* @return Whether it is possible for the child view of this layout to
* scroll up. Override this if the child view is a custom view.
*/
public boolean canChildScrollUp() {
if (android.os.Build.VERSION.SDK_INT < 14) {
if (mTarget instanceof AbsListView) {
final AbsListView absListView = (AbsListView) mTarget;
return absListView.getChildCount() > 0
&& (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0)
http://blog.denevell.org/android-viewdraghelper-example-tutorial.html
public static Bitmap getViewBitmap(View v) {
v.clearFocus();
v.setPressed(false);
boolean willNotCache = v.willNotCacheDrawing();
v.setWillNotCacheDrawing(false);
// Reset the drawing cache background color to fully transparent
// for the duration of this operation
int color = v.getDrawingCacheBackgroundColor();
protected void cancelContentTouch() {
final long now = SystemClock.uptimeMillis();
final MotionEvent cancelEvent = MotionEvent.obtain(now, now, MotionEvent.ACTION_CANCEL, 0.0f, 0.0f, 0);
final int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
getChildAt(i).dispatchTouchEvent(cancelEvent);
}
mContentContainer.dispatchTouchEvent(cancelEvent);
cancelEvent.recycle();
}
@ixiyang
ixiyang / demo
Created August 1, 2014 00:57
disable webview zoom
WebSettings settings = webView.getSettings();
settings.setJavaScriptEnabled(true);
settings.setLoadsImagesAutomatically(true);
settings.setBuiltInZoomControls(false);
if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.KITKAT) {
settings.setUseWideViewPort(true);
}else {
settings.setUseWideViewPort(false);
}
@ixiyang
ixiyang / WebviewFragment
Last active August 29, 2015 14:04
webview file upload,handle 4.4.x
public class WebFragment extends Fragment implements OnRefreshListener<WebView> {
public static final String TAG = "WebFragment";
public static final String URL = "url";
public static final String IS_SINGLE_COLUMN = "is_single_column";
private String url;
PullToRefreshWebView refreshWebView;
private WebView webView;
private ProgressBar progressBar;
private boolean isSingleColumn;
private ValueCallback<Uri> mUploadMessage;