本文主要是记录一些零碎的东西
项目地址:https://github.com/CL-window/MyView
1 . 实现三个button ,可以左右滑动(动画效果),中间的一个突出显示(放大)
其实没啥,就是监听了滑动事件,只是动画太丑
/**
* <p>Description: 中间突出的滑动 button </p>
* Created by slack on 2016/7/11 11:00 .
* 动画添加失败,以后再处理
*/
public class showCenter extends LinearLayout implements View.OnClickListener {
private double downX,upX;
private double threshold = 30;// 滑动阈值
private int[] smallIco = {R.drawable.video,R.drawable.camera,R.drawable.gifp};// 小图 录像 拍照 gif
private int[] bigIco = {R.drawable.video_large,R.drawable.camera_large,R.drawable.gifp_large};// 录像 拍照 gif
private String[] bigIcoInfo = {"录像", "拍照", "GIF"};
private int centerSelect = 1;
private View view;
private ImageView leftImage,centerImage,rightImage,tempImage;
private TextView centerInfo;
private ShowCenterListener mShowCenterListener;
public showCenter(Context context) {
super(context);
}
public showCenter(Context context, AttributeSet attrs) {
super(context, attrs);
// setWillNotDraw(false);// 关于onDraw()方法不被执行的解决方法
view = LayoutInflater.from(context).inflate(R.layout.bottomview, this);
initView();
initListener();
}
private void initView() {
leftImage = (ImageView) view.findViewById(R.id.bottom_view_left);
centerImage =(ImageView) view.findViewById(R.id.bottom_view_center_big);
rightImage = (ImageView)view.findViewById(R.id.bottom_view_right);
centerInfo = (TextView)view.findViewById(R.id.bottom_view_center_info);
}
private void initListener() {
view.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
switch (motionEvent.getAction()){
case MotionEvent.ACTION_DOWN:
downX = motionEvent.getX();
// Log.i("slack","ACTION_DOWN..."+downX);
break;
case MotionEvent.ACTION_MOVE:
// Log.i("slack","ACTION_MOVE...");
// 滑动中开始动画
break;
case MotionEvent.ACTION_UP:
upX = motionEvent.getX();
// Log.i("slack","ACTION_UP..."+upX);
if(downX - upX > threshold){
Log.i("slack","left...1");
leftSelect();
}else if(upX - downX > threshold){
Log.i("slack","right...1");
rightSelect();
}
// invalidate();//