Android 自定义ListView和GridView

}

isRecored = false;

isBack = false;

break;

case MotionEvent.ACTION_MOVE:

int tempY = (int) event.getY();

if (!isRecored && firstItemIndex == 0) {

Log.e(TAG, “MotionEvent.ACTION_MOVE”);

isRecored = true;

startY = tempY;

}

if (state != REFRESHING && isRecored && state != LOADING) {

// 保证在设置padding的过程中,当前的位置一直是在head,否则如果当列表超出屏幕的话,当在上推的时候,列表会同时进行滚动

// 可以松手去刷新了

if (state == RELEASE_TO_REFRESH) {

setSelection(0);

// 往上推了,推到了屏幕足够掩盖head的程度,但是还没有推到全部掩盖的地步

if (((tempY - startY) / RATIO < headContentHeight)

&& (tempY - startY) > 0) {

state = PULL_TO_REFRESH;

changeHeaderViewByState();

Log.e(TAG, “由松开刷新状态转变到下拉刷新状态”);

}

// 一下子推到顶了

else if (tempY - startY <= 0) {

state = DONE;

changeHeaderViewByState();

Log.e(TAG, “由松开刷新状态转变到done状态”);

}

// 往下拉了,或者还没有上推到屏幕顶部掩盖head的地步

else {

// 不用进行特别的操作,只用更新paddingTop的值就行了

}

}

// 还没有到达显示松开刷新的时候,DONE或者是PULL_To_REFRESH状态

if (state == PULL_TO_REFRESH) {

setSelection(0);

// 下拉到可以进入RELEASE_TO_REFRESH的状态

if ((tempY - startY) / RATIO >= headContentHeight) {

state = RELEASE_TO_REFRESH;

isBack = true;

changeHeaderViewByState();

Log.e(TAG, “由done或者下拉刷新状态转变到松开刷新”);

}

// 上推到顶了

else if (tempY - startY <= 0) {

state = DONE;

changeHeaderViewByState();

Log.e(TAG, “由Done或者下拉刷新状态转变到done状态”);

}

}

// done状态下

if (state == DONE) {

if (tempY - startY > 0) {

state = PULL_TO_REFRESH;

changeHeaderViewByState();

}

}

// 更新headView的size

if (state == PULL_TO_REFRESH) {

headView.setPadding(0, -1 * headContentHeight

  • (tempY - startY) / RATIO, 0, 0);

}

// 更新headView的paddingTop

if (state == RELEASE_TO_REFRESH) {

headView.setPadding(0, (tempY - startY) / RATIO

  • headContentHeight, 0, 0);

}

}

break;

}

}

return super.onTouchEvent(event);

}

// 当状态改变时候,调用该方法,以更新界面

private void changeHeaderViewByState() {

switch (state) {

case RELEASE_TO_REFRESH:

arrowImageView.setVisibility(View.VISIBLE);

progressBar.setVisibility(View.GONE);

tipsTextview.setVisibility(View.VISIBLE);

lastUpdatedTextView.setVisibility(View.VISIBLE);

arrowImageView.clearAnimation();

arrowImageView.startAnimation(animation);

tipsTextview.setText(“放开以刷新”);

Log.e(TAG, “State–>RELEASE_TO_REFRESH”);

break;

case PULL_TO_REFRESH:

progressBar.setVisibility(View.GONE);

tipsTextview.setVisibility(View.VISIBLE);

lastUpdatedTextView.setVisibility(View.VISIBLE);

arrowImageView.clearAnimation();

arrowImageView.setVisibility(View.VISIBLE);

// 是由RELEASE_To_REFRESH状态转变来的

if (isBack) {

isBack = false;

arrowImageView.clearAnimation();

arrowImageView.startAnimation(reverseAnimation);

tipsTextview.setText(“下拉刷新”);

} else {

tipsTextview.setText(“下拉刷新”);

}

Log.e(TAG, “State–>PULL_TO_REFRESH”);

break;

case REFRESHING:

headView.setPadding(0, 0, 0, 0);

progressBar.setVisibility(View.VISIBLE);

arrowImageView.clearAnimation();

arrowImageView.setVisibility(View.GONE);

tipsTextview.setText(“正在刷新…”);

lastUpdatedTextView.setVisibility(View.VISIBLE);

Log.e(TAG, “State–>REFRESHING”);

break;

case DONE:

headView.setPadding(0, -1 * headContentHeight, 0, 0);

progressBar.setVisibility(View.GONE);

arrowImageView.clearAnimation();

arrowImageView.setImageResource(R.drawable.ic_launcher);

tipsTextview.setText(“下拉刷新”);

lastUpdatedTextView.setVisibility(View.VISIBLE);

Log.e(TAG, “State–>DONE”);

break;

}

}

public void setonRefreshListener(OnRefreshListener refreshListener) {

this.refreshListener = refreshListener;

isRefreshable = true;

}

public interface OnRefreshListener {

public void onRefresh();

}

public void onRefreshComplete() {

state = DONE;

lastUpdatedTextView.setText(“最近更新:” + new Date().toLocaleString());

changeHeaderViewByState();

}

private void onRefresh() {

if (refreshListener != null) {

refreshListener.onRefresh();

}

}

// 此方法直接照搬自网络上的一个下拉刷新的demo,此处是“估计”headView的width以及height

private void measureView(View child) {

ViewGroup.LayoutParams p = child.getLayoutParams();

if (p == null) {

p = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,

ViewGroup.LayoutParams.WRAP_CONTENT);

}

int childWidthSpec = ViewGroup.getChildMeasureSpec(0, 0 + 0, p.width);

int lpHeight = p.height;

int childHeightSpec;

if (lpHeight > 0) {

childHeightSpec = MeasureSpec.makeMeasureSpec(lpHeight,

MeasureSpec.EXACTLY);

} else {

childHeightSpec = MeasureSpec.makeMeasureSpec(0,

MeasureSpec.UNSPECIFIED);

}

child.measure(childWidthSpec, childHeightSpec);

}

public void setAdapter(BaseAdapter adapter) {

// {@ TChip ZJ:设置Header中最近更新时间 @}

lastUpdatedTextView.setText(“最近更新:” + new Date().toLocaleString());

super.setAdapter(adapter);

}

}

代码下载

2.自定义可拖动的GridView

效果预览:

代码

MainActivity:

package com.example.draggridview;

import java.util.ArrayList;

import java.util.Collections;

import java.util.HashMap;

import java.util.List;

import java.util.Random;

import com.example.framework.DragGridBaseAdapter;

import com.example.framework.DragGridView;

import android.app.Activity;

import android.content.Context;

import android.os.Bundle;

import android.view.LayoutInflater;

import android.view.View;

import android.view.View.OnClickListener;

import android.view.ViewGroup;

import android.view.WindowManager;

import android.widget.BaseAdapter;

import android.widget.Button;

import android.widget.ImageView;

import android.widget.TextView;

import android.widget.Toast;

public class MainActivity extends Activity {

private List<HashMap<String, Object>> dataSourceList = new ArrayList<HashMap<String, Object>>();

private DragGridView mDragGridView = null;

private Button btnRefresh;

private Button btnFull;

private Button btnFullCancel;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

TextView tvNum = (TextView) findViewById(R.id.tvNum);

btnRefresh = (Button) findViewById(R.id.btnRefresh);

btnFull = (Button) findViewById(R.id.btnFull);

btnFullCancel = (Button) findViewById(R.id.btnFullCancel);

mDragGridView = (DragGridView) findViewById(R.id.dragGridView);

int red = 0;

int blue = 0;

dataSourceList.clear();

for (int i = 1; i < 97; i++) {

HashMap<String, Object> itemHashMap = new HashMap<String, Object>();

itemHashMap.put(“item_text”, “Icon” + Integer.toString(i));

int randomNUm = new Random().nextInt(2);

if (randomNUm % 2 == 0) {

itemHashMap.put(“item_icon”, R.drawable.check);

blue++;

} else {

itemHashMap.put(“item_icon”, R.drawable.star);

red++;

}

dataSourceList.add(itemHashMap);

}

mDragGridView.setAdapter(new DragAdapter(this, dataSourceList));

tvNum.setText(“Red:” + red + " Blue" + blue);

btnRefresh.setOnClickListener(new onClickListenerImp());

btnFull.setOnClickListener(new onClickListenerImp());

btnFullCancel.setOnClickListener(new onClickListenerImp());

}

// OnClickListener

class onClickListenerImp implements OnClickListener {

@Override

public void onClick(View v) {

// TODO Auto-generated method stub

if (v == btnRefresh) {

mDragGridView = (DragGridView) findViewById(R.id.dragGridView);

onCreate(null);

} else if (v == btnFull) {

getWindow().setFlags(

WindowManager.LayoutParams.FLAG_FULLSCREEN,

WindowManager.LayoutParams.FLAG_FULLSCREEN);

btnFullCancel.setVisibility(View.VISIBLE);

btnFull.setVisibility(View.GONE);

} else if (v == btnFullCancel) {

//isFull = getWindow().getAttributes().flags;

getWindow().clearFlags(

WindowManager.LayoutParams.FLAG_FULLSCREEN);

btnFullCancel.setVisibility(View.GONE);

btnFull.setVisibility(View.VISIBLE);

}

}

}

// Adapter

class DragAdapter extends BaseAdapter implements DragGridBaseAdapter {

private List<HashMap<String, Object>> list;

private LayoutInflater mInflater;

private int mHidePosition = -1;

public DragAdapter(Context context, List<HashMap<String, Object>> list) {

this.list = list;

mInflater = LayoutInflater.from(context);

}

@Override

public int getCount() {

return list.size();

}

@Override

public Object getItem(int position) {

return list.get(position);

}

@Override

public long getItemId(int position) {

return position;

}

@Override

public View getView(int position, View convertView, ViewGroup parent) {

convertView = mInflater.inflate(R.layout.grid_item, null);

ImageView mImageView = (ImageView) convertView

.findViewById(R.id.item_icon);

TextView mTextView = (TextView) convertView

.findViewById(R.id.item_text);

mImageView.setImageResource((Integer) list.get(position).get(

“item_icon”));

mTextView.setText((CharSequence) list.get(position)

.get(“item_text”));

if (position == mHidePosition) {

convertView.setVisibility(View.INVISIBLE);

}

return convertView;

}

@Override

public void reorderItems(int oldPosition, int newPosition) {

HashMap<String, Object> temp = list.get(oldPosition);

if (oldPosition < newPosition) {

for (int i = oldPosition; i < newPosition; i++) {

Collections.swap(list, i, i + 1);

}

} else if (oldPosition > newPosition) {

for (int i = oldPosition; i > newPosition; i–) {

Collections.swap(list, i, i - 1);

}

}

list.set(newPosition, temp);

}

@Override

public void setHideItem(int hidePosition) {

this.mHidePosition = hidePosition;

notifyDataSetChanged();

}

}

}

DragGridView:

package com.example.framework;

import java.util.LinkedList;

import java.util.List;

import android.app.Activity;

import android.content.Context;

import android.graphics.Bitmap;

import android.graphics.PixelFormat;

import android.graphics.Rect;

import android.os.Handler;

import android.os.Vibrator;

import android.util.AttributeSet;

import android.view.Gravity;

import android.view.MotionEvent;

import android.view.View;

import android.view.ViewTreeObserver;

import android.view.ViewTreeObserver.OnPreDrawListener;

import android.view.WindowManager;

import android.view.animation.AccelerateDecelerateInterpolator;

import android.widget.AdapterView;

import android.widget.GridView;

import android.widget.ImageView;

import android.widget.ListAdapter;

import com.nineoldandroids.animation.Animator;

import com.nineoldandroids.animation.AnimatorListenerAdapter;

import com.nineoldandroids.animation.AnimatorSet;

import com.nineoldandroids.animation.ObjectAnimator;

public class DragGridView extends GridView {

// DragGridView的item长按响应的时间

private long dragResponseMS = 500;

// 是否可以拖拽,默认不可以

private boolean isDrag = false;

private int mDownX;

private int mDownY;

private int moveX;

private int moveY;

// 正在拖拽的position

private int mDragPosition;

// 刚开始拖拽的item对应的View

private View mStartDragItemView = null;

// 用于拖拽的镜像,这里直接用一个ImageView

private ImageView mDragImageView;

// 震动器

private Vibrator mVibrator;

private WindowManager mWindowManager;

// item镜像的布局参数

private WindowManager.LayoutParams mWindowLayoutParams;

// 我们拖拽的item对应的Bitmap

private Bitmap mDragBitmap;

private int mPoint2ItemTop; // 按下的点到所在item的上边缘的距离

private int mPoint2ItemLeft; // 按下的点到所在item的左边缘的距离

private int mOffset2Top; // DragGridView距离屏幕顶部的偏移量

private int mOffset2Left; // DragGridView距离屏幕左边的偏移量

private int mStatusHeight; // 状态栏的高度

private int mDownScrollBorder; // DragGridView自动向下滚动的边界值

private int mUpScrollBorder; // DragGridView自动向上滚动的边界值

private static final int speed = 20; // DragGridView自动滚动的速度

private boolean mAnimationEnd = true;

private DragGridBaseAdapter mDragAdapter;

private int mNumColumns;

private int mColumnWidth;

private boolean mNumColumnsSet;

private int mHorizontalSpacing;

public DragGridView(Context context) {

this(context, null);

}

public DragGridView(Context context, AttributeSet attrs) {

this(context, attrs, 0);

}

public DragGridView(Context context, AttributeSet attrs, int defStyle) {

super(context, attrs, defStyle);

mVibrator = (Vibrator) context

.getSystemService(Context.VIBRATOR_SERVICE);

mWindowManager = (WindowManager) context

.getSystemService(Context.WINDOW_SERVICE);

mStatusHeight = getStatusHeight(context); // 获取状态栏的高度

if (!mNumColumnsSet) {

mNumColumns = AUTO_FIT;

}

}

private Handler mHandler = new Handler();

// 用来处理是否为长按的Runnable

private Runnable mLongClickRunnable = new Runnable() {

@Override

public void run() {

isDrag = true; // 设置可以拖拽

//mVibrator.vibrate(50); // 震动一下

mStartDragItemView.setVisibility(View.INVISIBLE); // 隐藏该item

// 根据我们按下的点显示item镜像

createDragImage(mDragBitmap, mDownX, mDownY);

}

};

@Override

public void setAdapter(ListAdapter adapter) {

super.setAdapter(adapter);

if (adapter instanceof DragGridBaseAdapter) {

mDragAdapter = (DragGridBaseAdapter) adapter;

} else {

throw new IllegalStateException(

“the adapter must be implements DragGridAdapter”);

}

}

@Override

public void setNumColumns(int numColumns) {

super.setNumColumns(numColumns);

mNumColumnsSet = true;

this.mNumColumns = numColumns;

}

@Override

public void setColumnWidth(int columnWidth) {

super.setColumnWidth(columnWidth);

mColumnWidth = columnWidth;

}

@Override

public void setHorizontalSpacing(int horizontalSpacing) {

super.setHorizontalSpacing(horizontalSpacing);

this.mHorizontalSpacing = horizontalSpacing;

}

@Override

protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

if (mNumColumns == AUTO_FIT) {

int numFittedColumns;

if (mColumnWidth > 0) {

int gridWidth = Math.max(MeasureSpec.getSize(widthMeasureSpec)

  • getPaddingLeft() - getPaddingRight(), 0);

numFittedColumns = gridWidth / mColumnWidth;

if (numFittedColumns > 0) {

while (numFittedColumns != 1) {

if (numFittedColumns * mColumnWidth

  • (numFittedColumns - 1) * mHorizontalSpacing > gridWidth) {

numFittedColumns–;

} else {

break;

}

}

} else {

numFittedColumns = 1;

}

} else {

numFittedColumns = 2;

}

mNumColumns = numFittedColumns;

}

super.onMeasure(widthMeasureSpec, heightMeasureSpec);

}

// 设置响应拖拽的毫秒数,默认是1000毫秒

public void setDragResponseMS(long dragResponseMS) {

this.dragResponseMS = dragResponseMS;

}

@Override

public boolean dispatchTouchEvent(MotionEvent ev) {

switch (ev.getAction()) {

case MotionEvent.ACTION_DOWN:

mDownX = (int) ev.getX();

mDownY = (int) ev.getY();

// 根据按下的X,Y坐标获取所点击item的position

mDragPosition = pointToPosition(mDownX, mDownY);

if (mDragPosition == AdapterView.INVALID_POSITION) {

return super.dispatchTouchEvent(ev);

}

// 使用Handler延迟dragResponseMS执行mLongClickRunnable

mHandler.postDelayed(mLongClickRunnable, dragResponseMS);

// 根据position获取该item所对应的View

mStartDragItemView = getChildAt(mDragPosition

  • getFirstVisiblePosition());

mPoint2ItemTop = mDownY - mStartDragItemView.getTop();

mPoint2ItemLeft = mDownX - mStartDragItemView.getLeft();

mOffset2Top = (int) (ev.getRawY() - mDownY);

mOffset2Left = (int) (ev.getRawX() - mDownX);

// 获取DragGridView自动向上滚动的偏移量,小于这个值,DragGridView向下滚动

mDownScrollBorder = getHeight() / 5;

// 获取DragGridView自动向下滚动的偏移量,大于这个值,DragGridView向上滚动

mUpScrollBorder = getHeight() * 4 / 5;

// 开启mDragItemView绘图缓存

mStartDragItemView.setDrawingCacheEnabled(true);

// 获取mDragItemView在缓存中的Bitmap对象

mDragBitmap = Bitmap.createBitmap(mStartDragItemView

.getDrawingCache());

// 这一步很关键,释放绘图缓存,避免出现重复的镜像

mStartDragItemView.destroyDrawingCache();

break;

case MotionEvent.ACTION_MOVE:

int moveX = (int) ev.getX();

int moveY = (int) ev.getY();

// 如果我们在按下的item上面移动,只要不超过item的边界我们就不移除mRunnable

if (!isTouchInItem(mStartDragItemView, moveX, moveY)) {

mHandler.removeCallbacks(mLongClickRunnable);

}

break;

case MotionEvent.ACTION_UP:

mHandler.removeCallbacks(mLongClickRunnable);

mHandler.removeCallbacks(mScrollRunnable);

break;

}

return super.dispatchTouchEvent(ev);

}

/**

  • 是否点击在GridView的item上面

  • @param itemView

  • @param x

  • @param y

  • @return

*/

private boolean isTouchInItem(View dragView, int x, int y) {

if (dragView == null) {

return false;

}

int leftOffset = dragView.getLeft();

int topOffset = dragView.getTop();

if (x < leftOffset || x > leftOffset + dragView.getWidth()) {

return false;

}

if (y < topOffset || y > topOffset + dragView.getHeight()) {

return false;

}

return true;

}

@Override

public boolean onTouchEvent(MotionEvent ev) {

if (isDrag && mDragImageView != null) {

switch (ev.getAction()) {

case MotionEvent.ACTION_MOVE:

moveX = (int) ev.getX();

moveY = (int) ev.getY();

// 拖动item

onDragItem(moveX, moveY);

break;

case MotionEvent.ACTION_UP:

onStopDrag();

isDrag = false;

break;

}

return true;

}

return super.onTouchEvent(ev);

}

/**

  • 创建拖动的镜像

  • @param bitmap

  • @param downX

  •        按下的点相对父控件的X坐标
    
  • @param downY

  •        按下的点相对父控件的X坐标
    

*/

private void createDragImage(Bitmap bitmap, int downX, int downY) {

mWindowLayoutParams = new WindowManager.LayoutParams();

mWindowLayoutParams.format = PixelFormat.TRANSLUCENT; // 图片之外的其他地方透明

mWindowLayoutParams.gravity = Gravity.TOP | Gravity.LEFT;

mWindowLayoutParams.x = downX - mPoint2ItemLeft + mOffset2Left;

mWindowLayoutParams.y = downY - mPoint2ItemTop + mOffset2Top

  • mStatusHeight;

mWindowLayoutParams.alpha = 0.55f; // 透明度

mWindowLayoutParams.width = WindowManager.LayoutParams.WRAP_CONTENT;

mWindowLayoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;

mWindowLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE

| WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;

mDragImageView = new ImageView(getContext());

mDragImageView.setImageBitmap(bitmap);

mWindowManager.addView(mDragImageView, mWindowLayoutParams);

}

// 从界面上面移动拖动镜像

private void removeDragImage() {

if (mDragImageView != null) {

mWindowManager.removeView(mDragImageView);

mDragImageView = null;

}

}

/**

  • 拖动item,在里面实现了item镜像的位置更新,item的相互交换以及GridView的自行滚动

  • @param x

  • @param y

*/

private void onDragItem(int moveX, int moveY) {

mWindowLayoutParams.x = moveX - mPoint2ItemLeft + mOffset2Left;

mWindowLayoutParams.y = moveY - mPoint2ItemTop + mOffset2Top

  • mStatusHeight;

mWindowManager.updateViewLayout(mDragImageView, mWindowLayoutParams);

onSwapItem(moveX, moveY);

// GridView自动滚动

mHandler.post(mScrollRunnable);

}

/**

  • 当moveY的值大于向上滚动的边界值,触发GridView自动向上滚动 当moveY的值小于向下滚动的边界值,触犯GridView自动向下滚动

  • 否则不进行滚动

*/

private Runnable mScrollRunnable = new Runnable() {

@Override

public void run() {

int scrollY;

if (getFirstVisiblePosition() == 0

|| getLastVisiblePosition() == getCount() - 1) {

mHandler.removeCallbacks(mScrollRunnable);

}

if (moveY > mUpScrollBorder) {

scrollY = speed;

mHandler.postDelayed(mScrollRunnable, 25);

} else if (moveY < mDownScrollBorder) {

scrollY = -speed;

mHandler.postDelayed(mScrollRunnable, 25);

} else {

scrollY = 0;

mHandler.removeCallbacks(mScrollRunnable);

}

smoothScrollBy(scrollY, 10);

}

};

// 交换item,并且控制item之间的显示与隐藏效果

private void onSwapItem(int moveX, int moveY) {

// 获取我们手指移动到的那个item的position

final int tempPosition = pointToPosition(moveX, moveY);

// 假如tempPosition 改变了并且tempPosition不等于-1,则进行交换

if (tempPosition != mDragPosition

&& tempPosition != AdapterView.INVALID_POSITION

&& mAnimationEnd) {

mDragAdapter.reorderItems(mDragPosition, tempPosition);

mDragAdapter.setHideItem(tempPosition);

final ViewTreeObserver observer = getViewTreeObserver();

observer.addOnPreDrawListener(new OnPreDrawListener() {

@Override

public boolean onPreDraw() {

observer.removeOnPreDrawListener(this);

animateReorder(mDragPosition, tempPosition);

mDragPosition = tempPosition;

return true;

}

});

}

}

private AnimatorSet createTranslationAnimations(View view, float startX,

float endX, float startY, float endY) {

ObjectAnimator animX = ObjectAnimator.ofFloat(view, “translationX”,

startX, endX);

ObjectAnimator animY = ObjectAnimator.ofFloat(view, “translationY”,

startY, endY);

AnimatorSet animSetXY = new AnimatorSet();

animSetXY.playTogether(animX, animY);

return animSetXY;

}

private void animateReorder(final int oldPosition, final int newPosition) {

boolean isForward = newPosition > oldPosition;

List resultList = new LinkedList();

if (isForward) {

for (int pos = oldPosition; pos < newPosition; pos++) {

View view = getChildAt(pos - getFirstVisiblePosition());

System.out.println(pos);

if ((pos + 1) % mNumColumns == 0) {

resultList.add(createTranslationAnimations(view,

-view.getWidth() * (mNumColumns - 1), 0,

view.getHeight(), 0));

} else {

resultList.add(createTranslationAnimations(view,

view.getWidth(), 0, 0, 0));

}

}

} else {

for (int pos = oldPosition; pos > newPosition; pos–) {

View view = getChildAt(pos - getFirstVisiblePosition());

最后

其实Android开发的知识点就那么多,面试问来问去还是那么点东西。所以面试没有其他的诀窍,只看你对这些知识点准备的充分程度。so,出去面试时先看看自己复习到了哪个阶段就好。

上面分享的腾讯、头条、阿里、美团、字节跳动等公司2019-2021年的高频面试题,博主还把这些技术点整理成了视频和PDF(实际上比预期多花了不少精力),包含知识脉络 + 诸多细节,由于篇幅有限,上面只是以图片的形式给大家展示一部分。

【Android思维脑图(技能树)】

知识不体系?这里还有整理出来的Android进阶学习的思维脑图,给大家参考一个方向。

【Android高级架构视频学习资源】
《Android学习笔记总结+移动架构视频+大厂面试真题+项目实战源码》点击传送门,即可获取!
ateTranslationAnimations(View view, float startX,

float endX, float startY, float endY) {

ObjectAnimator animX = ObjectAnimator.ofFloat(view, “translationX”,

startX, endX);

ObjectAnimator animY = ObjectAnimator.ofFloat(view, “translationY”,

startY, endY);

AnimatorSet animSetXY = new AnimatorSet();

animSetXY.playTogether(animX, animY);

return animSetXY;

}

private void animateReorder(final int oldPosition, final int newPosition) {

boolean isForward = newPosition > oldPosition;

List resultList = new LinkedList();

if (isForward) {

for (int pos = oldPosition; pos < newPosition; pos++) {

View view = getChildAt(pos - getFirstVisiblePosition());

System.out.println(pos);

if ((pos + 1) % mNumColumns == 0) {

resultList.add(createTranslationAnimations(view,

-view.getWidth() * (mNumColumns - 1), 0,

view.getHeight(), 0));

} else {

resultList.add(createTranslationAnimations(view,

view.getWidth(), 0, 0, 0));

}

}

} else {

for (int pos = oldPosition; pos > newPosition; pos–) {

View view = getChildAt(pos - getFirstVisiblePosition());

最后

其实Android开发的知识点就那么多,面试问来问去还是那么点东西。所以面试没有其他的诀窍,只看你对这些知识点准备的充分程度。so,出去面试时先看看自己复习到了哪个阶段就好。

上面分享的腾讯、头条、阿里、美团、字节跳动等公司2019-2021年的高频面试题,博主还把这些技术点整理成了视频和PDF(实际上比预期多花了不少精力),包含知识脉络 + 诸多细节,由于篇幅有限,上面只是以图片的形式给大家展示一部分。

【Android思维脑图(技能树)】

知识不体系?这里还有整理出来的Android进阶学习的思维脑图,给大家参考一个方向。

[外链图片转存中…(img-CSNDPFOb-1714691104384)]

【Android高级架构视频学习资源】
《Android学习笔记总结+移动架构视频+大厂面试真题+项目实战源码》点击传送门,即可获取!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值