This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OverScroller | |
startScroll() 开始滚动 | |
computeScrollOffset() 方法不断计算滚动到的最新的位置,当滚动动画结束时,方法返回false。所以通常使用以下方式不断根据最新的位置绘制view来达到滚动的效果 | |
if (mScroller.computeScrollOffset()) { | |
// This is called at drawing time by ViewGroup. We use | |
// this method to keep the fling animation going through | |
// to completion. | |
int oldX = getScrollX(); | |
int oldY = getScrollY(); | |
int x = mScroller.getCurrX(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
matrix代表一个3*3矩阵,其内容如下 | |
MSCALE_X MSKEW_X MTRANS_X | |
MSKEW_Y MSKEW_Y MTRANS_Y | |
MPERSP_0 MPERSP_1 MPERSP_2 | |
Matrix matrix=new Matrix(); | |
System.err.println(matrix.toShortString()); | |
matrix.postScale(2, 3); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RotateZoomImageView extends ImageView { | |
private ScaleGestureDetector mScaleDetector; | |
private Matrix mImageMatrix; | |
/* Last Rotation Angle */ | |
private int mLastAngle = 0; | |
/* Pivot Point for Transforms */ | |
private int mPivotX, mPivotY; | |
private float mStartX, mStartY; | |
public RotateZoomImageView(Context context) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rect rect = new Rect(); | |
int childCount = mListView.getChildCount(); | |
int[] listViewCoords = new int[2]; | |
mListView.getLocationOnScreen(listViewCoords); | |
System.err.println("listViewCoords[0]====>"+listViewCoords[0]); | |
System.err.println("listViewCoords[1]====>"+listViewCoords[1]); | |
int x = (int) motionEvent.getRawX() - listViewCoords[0]; | |
int y = (int) motionEvent.getRawY() - listViewCoords[1]; | |
View child; | |
for (int i = 0; i < childCount; i++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:adjustViewBounds="true" | |
android:scaleType="fitCenter" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ResizableImageView extends ImageView { | |
public ResizableImageView(Context context, AttributeSet attrs) { | |
super(context, attrs); | |
} | |
@Override | |
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec){ | |
Drawable d = getDrawable(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String getPath(Uri uri) { | |
String siPath; | |
// 1:MEDIA GALLERY --- query from MediaStore.Images.Media.DATA | |
String[] projection = { MediaStore.Images.Media.DATA }; | |
Cursor cursor = managedQuery(uri, projection, null, null, null); | |
if (cursor != null) { | |
int column_index = cursor | |
.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); | |
cursor.moveToFirst(); | |
siPath = cursor.getString(column_index); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} |