实习笔记2

retrofit

  • 参考 -- Retrofit + RxJava + OkHttp 让网络请求变的简单-基础篇

在安卓中显示gif图片

使用WebView


runWebView.loadDataWithBaseURL(null,
"
    
        
", "text/html", "UTF-8",null);

实现底部状态栏

使用recyclerview + gridlayoutmanager

    val rc_btm_navi = findViewById(R.id.rc_btm_navi)
    rc_btm_navi.layoutManager = GridLayoutManager(this,1).apply {
        orientation = GridLayoutManager.HORIZONTAL
    }
    rc_btm_navi.adapter = navi_adapter()

adaper中获取屏幕宽度,创建view时设置view的宽度

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): view_holder {
    val view: View =
        LayoutInflater.from(parent.context)
            .inflate(
                R.layout.item_navi,
                parent,
                false
            )
    view.layoutParams.width = getScreenWidth(activity) / navi_arr.size
    return view_holder(view)
}

自定义下拉刷新(没学会)

  • TRANSLUCENT 半透明

rectF类

Rect F holds four float coordinates for a rectangle . The rectangle
is represented by the coordinates of its 4 edges ( left , top , right
bottom ). These fields can be accessed directly . Use width () and
height () to retrieve the rectangle ’ s width and height . Note :
most methods do not check to see that the coordinates are sorted
correctly ( i . e . left <= right and top <= bottom ).

ViewFlipper(翻转视图)

  • 就是首次安装软件后的功能介绍页面

使用

导入图片

    

        
        
        
        
        

    
//动态导入
for(int i = 0;i < resId.length;i++){
    vflp_help.addView(getImageView(resId[i]));
}
private ImageView getImageView(int resId){
    ImageView img = new ImageView(this);
    img.setBackgroundResource(resId);
    return img;
}

翻动

手动翻动

  • 自定义一个GestureListener
  • 创建一个GestureDetector
  • 重写activity的onTouchEvent
private class MyGestureListener extends GestureDetector.SimpleOnGestureListener {
    @Override
    public boolean onFling(MotionEvent e1, MotionEvent e2, float v, float v1) {
        if(e1.getX() - e2.getX() > MIN_MOVE){
            vflp_help.setInAnimation(mContext,R.anim.right_in);
            vflp_help.setOutAnimation(mContext, R.anim.right_out);
            vflp_help.showNext();
        }else if(e2.getX() - e1.getX() > MIN_MOVE){
            vflp_help.setInAnimation(mContext,R.anim.left_in);
            vflp_help.setOutAnimation(mContext, R.anim.left_out);
            vflp_help.showPrevious();
        }
        return true;
    }
}
@Override
public boolean onTouchEvent(MotionEvent event) {
    return mDetector.onTouchEvent(event);
}
//自动翻动
vflp_help.startFlipping();

fragment中实现触摸事件

参考

你可能感兴趣的:(实习笔记2)