com.blankj.utilcode.util.SizeUtils Java Examples

The following examples show how to use com.blankj.utilcode.util.SizeUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StudyFragment.java    From YCAudioPlayer with Apache License 2.0 6 votes vote down vote up
private void initYCRefreshView() {
    recyclerView.setLayoutManager(new LinearLayoutManager(activity));
    final RecycleViewItemLine line = new RecycleViewItemLine(activity, LinearLayout.HORIZONTAL,
            SizeUtils.dp2px(1), Color.parseColor("#f5f5f7"));
    recyclerView.addItemDecoration(line);
    adapter = new StudyAdapter(activity);
    recyclerView.setAdapter(adapter);
    addHeader();
    recyclerView.setRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            SwipeRefreshLayout swipeToRefresh = recyclerView.getSwipeToRefresh();
            if(swipeToRefresh.isRefreshing()){
                recyclerView.setRefreshing(false);
            }
        }
    });
}
 
Example #2
Source File: OnLineMusicFragment.java    From YCAudioPlayer with Apache License 2.0 6 votes vote down vote up
private void initRecyclerView() {
    recyclerView.setLayoutManager(new LinearLayoutManager(activity));
    final RecycleViewItemLine line = new RecycleViewItemLine(activity, LinearLayout.HORIZONTAL,
            SizeUtils.dp2px(1), Color.parseColor("#f5f5f7"));
    recyclerView.addItemDecoration(line);
    adapter = new OnLineMusicAdapter(activity);
    recyclerView.setAdapter(adapter);
    recyclerView.setRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            if(NetworkUtils.isConnected()){
                onLazyLoad();
            }else {
                ToastUtils.showRoundRectToast("没有网络");
            }
        }
    });
}
 
Example #3
Source File: InnovationFragment.java    From YCAudioPlayer with Apache License 2.0 6 votes vote down vote up
private void initYCRefreshView() {
    recyclerView.setLayoutManager(new LinearLayoutManager(activity));
    final RecycleViewItemLine line = new RecycleViewItemLine(activity, LinearLayout.HORIZONTAL,
            SizeUtils.dp2px(1), Color.parseColor("#f5f5f7"));
    recyclerView.addItemDecoration(line);
    adapter = new InnovationAdapter(activity);
    recyclerView.setAdapter(adapter);
    addHeader();
    recyclerView.setRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            SwipeRefreshLayout swipeToRefresh = recyclerView.getSwipeToRefresh();
            if(swipeToRefresh.isRefreshing()){
                recyclerView.setRefreshing(false);
            }
        }
    });

    //设置回收复用池大小,(如果一屏内相同类型的 View 个数比较多,需要设置一个合适的大小,防止来回滚动时重新创建 View)
    RecyclerView.RecycledViewPool viewPool = new RecyclerView.RecycledViewPool();
    recyclerView.getRecyclerView().setRecycledViewPool(viewPool);
    viewPool.setMaxRecycledViews(0, 20);
}
 
Example #4
Source File: LocalOfficeActivity.java    From YCAudioPlayer with Apache License 2.0 6 votes vote down vote up
private void initRecyclerView() {
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    final RecycleViewItemLine line = new RecycleViewItemLine(this, LinearLayout.HORIZONTAL,
            SizeUtils.dp2px(1), Color.parseColor("#f5f5f7"));
    recyclerView.addItemDecoration(line);
    adapter = new LocalOfficeAdapter(this);
    recyclerView.setAdapter(adapter);
    recyclerView.setRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            SwipeRefreshLayout swipeToRefresh = recyclerView.getSwipeToRefresh();
            if (swipeToRefresh.isRefreshing()) {
                recyclerView.setRefreshing(false);
            }else {
                initData();
            }
        }
    });
}
 
Example #5
Source File: LocalVideoActivity.java    From YCAudioPlayer with Apache License 2.0 6 votes vote down vote up
private void initRecyclerView() {
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    final RecycleViewItemLine line = new RecycleViewItemLine(this, LinearLayout.HORIZONTAL,
            SizeUtils.dp2px(1), Color.parseColor("#f5f5f7"));
    recyclerView.addItemDecoration(line);
    adapter = new LocalVideoAdapter(this);
    recyclerView.setAdapter(adapter);
    recyclerView.setRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            SwipeRefreshLayout swipeToRefresh = recyclerView.getSwipeToRefresh();
            if (swipeToRefresh.isRefreshing()) {
                recyclerView.setRefreshing(false);
            }else {
                initData();
            }
        }
    });
}
 
Example #6
Source File: LocalZipFileActivity.java    From YCAudioPlayer with Apache License 2.0 6 votes vote down vote up
private void initRecyclerView() {
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    final RecycleViewItemLine line = new RecycleViewItemLine(this, LinearLayout.HORIZONTAL,
            SizeUtils.dp2px(1), Color.parseColor("#f5f5f7"));
    recyclerView.addItemDecoration(line);
    adapter = new LocalOfficeAdapter(this);
    recyclerView.setAdapter(adapter);
    recyclerView.setRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            SwipeRefreshLayout swipeToRefresh = recyclerView.getSwipeToRefresh();
            if (swipeToRefresh.isRefreshing()) {
                recyclerView.setRefreshing(false);
            }else {
                initData();
            }
        }
    });
}
 
Example #7
Source File: CommonActivity.java    From AndroidUtilCode with Apache License 2.0 6 votes vote down vote up
private void initSwipeBack() {
    if (isSwipeBack()) {
        final SwipePanel swipeLayout = new SwipePanel(this);
        swipeLayout.setLeftDrawable(R.drawable.common_back);
        swipeLayout.setLeftEdgeSize(SizeUtils.dp2px(16));
        swipeLayout.setLeftSwipeColor(getResources().getColor(R.color.colorPrimary));
        swipeLayout.wrapView(findViewById(android.R.id.content));
        swipeLayout.setOnFullSwipeListener(new SwipePanel.OnFullSwipeListener() {
            @Override
            public void onFullSwipe(int direction) {
                swipeLayout.close(direction);
                finish();
            }
        });
    }
}
 
Example #8
Source File: DetailVideoActivity.java    From YCAudioPlayer with Apache License 2.0 6 votes vote down vote up
/**
 * 初始化指示器
 */
private void initIndicator() {
    tvTitleLeft.setText("课程简介");
    tvTitleRight.setText("课程目录课程目录");
    int spec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    tvTitleLeft.measure(spec,spec);
    tvTitleRight.measure(spec,spec);
    int widthLeft = tvTitleLeft.getMeasuredWidth();
    int widthRight = tvTitleRight.getMeasuredWidth();
    AppLogUtils.e("width"+tvTitleLeft.getWidth() + "---"+tvTitleRight.getWidth()
            + "---"+tvTitleLeft.getMeasuredWidth());
    AppLogUtils.e("width"+"----------"+widthLeft+"-----"+widthRight);
    LinearLayout.LayoutParams paramsLeft = new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, SizeUtils.dp2px(2));
    paramsLeft.width = widthLeft;
    viewLeft.setLayoutParams(paramsLeft);
    LinearLayout.LayoutParams paramsRight = new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, SizeUtils.dp2px(2));
    paramsRight.width = widthRight;
    viewRight.setLayoutParams(paramsRight);
    setViewIndicator(true);
}
 
Example #9
Source File: RvNoteListAdapter.java    From SuperNote with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 显示是否线性布局时的分组信息
 *
 * @param helper
 * @param isShow 是否显示
 * @param time   时间戳
 * @describe
 */
private void showLineraLayoutGroup(boolean isShow, BaseViewHolder helper, long time) {
    // 有分组的列,marginTop为8dp,否则,为0dp
    LinearLayout ll = helper.getView(R.id.ll_note_list_linear);
    LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) ll.getLayoutParams();
    if (isShow) {
        helper.setVisible(R.id.tv_note_list_linear_month, true);
        setLinearGroupStyle(helper, time);

        params.setMargins(SizeUtils.dp2px(0), SizeUtils.dp2px(8), SizeUtils.dp2px(0), SizeUtils.dp2px(0));
        ll.setLayoutParams(params);

    } else {
        helper.setVisible(R.id.tv_note_list_linear_month, false);
        params.setMargins(SizeUtils.dp2px(0), SizeUtils.dp2px(0), SizeUtils.dp2px(0), SizeUtils.dp2px(0));
        ll.setLayoutParams(params);
    }
}
 
Example #10
Source File: NoteMainActivity.java    From SuperNote with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void hideBottomBar() {
    // 下移动画
    ObjectAnimator animator = ObjectAnimator.ofFloat(mRlBottomBar, "translationY", SizeUtils.dp2px(56));
    animator.setDuration(300);
    animator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            mRlBottomBar.setVisibility(View.GONE);
        }
    });
    animator.start();
}
 
Example #11
Source File: GiftPopup.java    From EasyPopup with Apache License 2.0 5 votes vote down vote up
@Override
protected void initAttributes() {
    setContentView(R.layout.layout_gift);
    setHeight(SizeUtils.dp2px(200));
    setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
    setFocusAndOutsideEnable(true);
}
 
Example #12
Source File: NoteMainActivity.java    From SuperNote with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void showBottomBar() {
    mRlBottomBar.setVisibility(View.VISIBLE);
    //        bottombar进行一个上移的动画
    ObjectAnimator animator = ObjectAnimator.ofFloat(mRlBottomBar, "translationY", SizeUtils.dp2px(56), 0);
    animator.setDuration(300);
    animator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
        }
    });
    animator.start();
}
 
Example #13
Source File: ImageInfoActivity.java    From SuperNote with GNU General Public License v3.0 5 votes vote down vote up
private void showToolbarAndBottomBar() {
    mIsToolbarAndBottomBarHided = false;

    ObjectAnimator animator = ObjectAnimator.ofFloat(mAppBarLayout, "translationY", -SizeUtils.dp2px(56), 0);
    animator.setDuration(300);
    animator.start();

    ObjectAnimator animator1 = ObjectAnimator.ofFloat(mLlBottomBar, "translationY", SizeUtils.dp2px(56), 0);
    animator1.setDuration(300);
    animator1.start();
}
 
Example #14
Source File: ImageInfoActivity.java    From SuperNote with GNU General Public License v3.0 5 votes vote down vote up
private void hideToolbarAndBottomBar() {
    mIsToolbarAndBottomBarHided = true;

    ObjectAnimator animator = ObjectAnimator.ofFloat(mAppBarLayout, "translationY", 0, -SizeUtils.dp2px(56));
    animator.setDuration(300);
    animator.start();

    ObjectAnimator animator1 = ObjectAnimator.ofFloat(mLlBottomBar, "translationY", 0, SizeUtils.dp2px(56));
    animator1.setDuration(300);
    animator1.start();
}
 
Example #15
Source File: MyDrawable.java    From SuperNote with GNU General Public License v3.0 5 votes vote down vote up
public static GradientDrawable getIcFolderSelectedDrawable( int color){
    GradientDrawable gradientDrawable=new GradientDrawable();
    gradientDrawable.setShape(GradientDrawable.OVAL);
    gradientDrawable.setSize(SizeUtils.dp2px(24), SizeUtils.dp2px(24));
    gradientDrawable.setBounds(0,0,SizeUtils.dp2px(24), SizeUtils.dp2px(24));
    gradientDrawable.setColor(color);
    return gradientDrawable;
}
 
Example #16
Source File: LockView.java    From SuperNote with GNU General Public License v3.0 5 votes vote down vote up
private void measureDimension(int widthMeasureSpec,int heightMeasureSpec){
//        测量的值
        int measureWidth=0;
        int measureHeight=0;
//        默认值
        int defaultSize=400;

        int widthSpecMode= MeasureSpec.getMode(widthMeasureSpec);
        int heightSpcMode= MeasureSpec.getMode(heightMeasureSpec);
        int widthSpecSize= MeasureSpec.getSize(widthMeasureSpec);
        int heightSpecSize= MeasureSpec.getSize(heightMeasureSpec);
        switch (widthSpecMode){
            case MeasureSpec.EXACTLY:
                measureWidth=widthSpecSize;
                break;
            case MeasureSpec.UNSPECIFIED:
                measureWidth=SizeUtils.dp2px(defaultSize);
                break;
            case MeasureSpec.AT_MOST:
                measureWidth= Math.min(widthSpecSize,defaultSize);
                break;
        }
        switch (heightSpcMode){
            case MeasureSpec.EXACTLY:
                measureHeight=heightSpecSize;
                break;
            case MeasureSpec.UNSPECIFIED:
                measureHeight=SizeUtils.dp2px(defaultSize);
                break;
            case MeasureSpec.AT_MOST:
//                为了让解锁界面为方形,让高的值和宽一样。
                measureHeight=measureWidth;
                break;
        }
        setMeasuredDimension(measureWidth,measureHeight);

    }
 
Example #17
Source File: ThemeChoiceRadioButton.java    From SuperNote with GNU General Public License v3.0 5 votes vote down vote up
private void drawCorcle(Canvas canvas){

        Paint paint=new Paint();
        paint.setColor(backgroundColor);
        //  绘制圆形
        canvas.drawCircle(getMeasuredWidth()/2,getMeasuredHeight()/2, SizeUtils.dp2px(20),paint);

        //  绘制对勾
        if(isChecked()){
            Bitmap bitmap = BitmapFactory.decodeResource(this.getContext().getResources(), R.drawable.ic_check_white_24dp);
            canvas.drawBitmap(bitmap,getMeasuredWidth()/2-SizeUtils.dp2px(12),getMeasuredHeight()/2-SizeUtils.dp2px(12),paint);
        }
    }
 
Example #18
Source File: FloatToast.java    From AndroidUtilCode with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreateLayoutParams() {
    super.onCreateLayoutParams();

    mLayoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
    mLayoutParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
    mLayoutParams.windowAnimations = android.R.style.Animation_Toast;
    mLayoutParams.flags = WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
            | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
            | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
    mLayoutParams.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
    mLayoutParams.y = SizeUtils.dp2px(64);
}
 
Example #19
Source File: CmmtPopup.java    From EasyPopup with Apache License 2.0 5 votes vote down vote up
@Override
protected void initAttributes() {
    setContentView(R.layout.layout_cmmt, ViewGroup.LayoutParams.MATCH_PARENT, SizeUtils.dp2px(150));
    setFocusAndOutsideEnable(true)
            .setBackgroundDimEnable(true)
            .setAnimationStyle(R.style.BottomPopAnim)
            .setDimValue(0.5f)
            .setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED)
            .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
}
 
Example #20
Source File: NoteMainActivity.java    From SuperNote with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void hideAddFab() {
    ObjectAnimator animator = ObjectAnimator.ofFloat(mFabAdd, "translationY", SizeUtils.dp2px(80));
    animator.setDuration(150);
    animator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            mFabAdd.setVisibility(View.GONE);
        }
    });
    animator.start();
}
 
Example #21
Source File: DetailAudioFragment.java    From YCAudioPlayer with Apache License 2.0 5 votes vote down vote up
private void initToolBar() {
    int statusBarHeight = BarUtils.getStatusBarHeight();
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, SizeUtils.dp2px(50));
    params.topMargin = statusBarHeight;
    toolbar.setLayoutParams(params);
}
 
Example #22
Source File: EditNotePresenter.java    From SuperNote with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Bitmap getNoteShareBitmap(View view) {
    Bitmap bitmap = ImageUtils.view2Bitmap(view);
    int x = bitmap.getWidth() - SizeUtils.sp2px(72);
    int y = bitmap.getHeight() - SizeUtils.sp2px(16);
    int textWaterMarkColor = Utils.getContext().getResources().getColor(R.color.colorBlackAlpha54);
    bitmap = ImageUtils.addTextWatermark(bitmap, EditNoteConstans.watermarkText, 24, textWaterMarkColor, x, y);
    return bitmap;
}
 
Example #23
Source File: EditNotePresenter.java    From SuperNote with GNU General Public License v3.0 5 votes vote down vote up
@Override
public int getNoteEditNeedHeight() {
    // 屏幕高度减去 状态栏高度、toolbar高度、底部工具栏高度
    float height = ScreenUtils.getScreenHeight() - ThemeUtils.getStatusBarHeight()
            - SizeUtils.dp2px(56) - SizeUtils.dp2px(48);
    return (int) height;
}
 
Example #24
Source File: LockActivity.java    From SuperNote with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onError() {
    mTvTip.setText("请重试");
    ObjectAnimator animator = ObjectAnimator.ofFloat(mTvTip, "translationX", -SizeUtils.dp2px(8), SizeUtils.dp2px(8), 0);
    animator.setDuration(200);
    animator.start();
}
 
Example #25
Source File: DetailVideoActivity.java    From YCAudioPlayer with Apache License 2.0 5 votes vote down vote up
private void initCatalogueListView() {
    adapter.addHeader(new RecyclerArrayAdapter.ItemView() {
        @Override
        public View onCreateView(ViewGroup parent) {
            RecyclerView recyclerView = new RecyclerView(parent.getContext()) {
                /**
                 * 为了不打扰RecyclerView的滑动操作,可以这样处理
                 */
                @SuppressLint("ClickableViewAccessibility")
                @Override
                public boolean onTouchEvent(MotionEvent event) {
                    super.onTouchEvent(event);
                    return true;
                }
            };
            RecyclerView.LayoutParams layoutParams = new RecyclerView.LayoutParams(
                    ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            layoutParams.setMargins(0, 0, 0, 0);
            recyclerView.setLayoutParams(layoutParams);
            final MovieCatalogueAdapter narrowAdapter;
            recyclerView.setAdapter(narrowAdapter = new MovieCatalogueAdapter(parent.getContext()));
            recyclerView.setLayoutManager(new LinearLayoutManager(parent.getContext(), LinearLayoutManager.VERTICAL, false));
            recyclerView.addItemDecoration(new RecycleViewItemLine(parent.getContext(), SizeUtils.px2dp(1)));
            List<String> data = new ArrayList<>();
            for (int a = 0; a < 3; a++) {
                data.add("假数据" + a);
            }
            narrowAdapter.addAll(data);
            return recyclerView;
        }

        @Override
        public void onBindView(View headerView) {
            //这里的处理别忘了
            ((ViewGroup) headerView).requestDisallowInterceptTouchEvent(true);
        }
    });
}
 
Example #26
Source File: DetailVideoActivity.java    From YCAudioPlayer with Apache License 2.0 5 votes vote down vote up
private void initYCRefreshView() {
    linearLayoutManager = new LinearLayoutManager(this);
    recyclerView.setLayoutManager(linearLayoutManager);
    final RecycleViewItemLine line = new RecycleViewItemLine(this, LinearLayout.HORIZONTAL,
            SizeUtils.dp2px(1), Color.parseColor("#f5f5f7"));
    recyclerView.addItemDecoration(line);
    adapter = new DetailVideoAdapter(this);
    recyclerView.setAdapter(adapter);
    recyclerView.setRefreshing(false);
    recyclerView.scrollTo(0,0);
    recyclerView.scrollBy(0,0);
    addHeader();
}
 
Example #27
Source File: DetailAudioFragment.java    From YCAudioPlayer with Apache License 2.0 5 votes vote down vote up
private void initYCRefreshView() {
    recyclerView.setLayoutManager(new LinearLayoutManager(activity));
    final RecycleViewItemLine line = new RecycleViewItemLine(activity, LinearLayout.HORIZONTAL,
            SizeUtils.dp2px(1), Color.parseColor("#f5f5f7"));
    recyclerView.addItemDecoration(line);
    adapter = new DetailAudioAdapter(activity);
    recyclerView.setAdapter(adapter);
    recyclerView.setRefreshing(false);
    addHeader();
}
 
Example #28
Source File: StudyFragment.java    From YCAudioPlayer with Apache License 2.0 4 votes vote down vote up
private void initHorizontalView() {
    adapter.addFooter(new RecyclerArrayAdapter.ItemView() {
        @Override
        public View onCreateView(ViewGroup parent) {
            RecyclerView recyclerView = new RecyclerView(parent.getContext()){
                //为了不打扰RecyclerView的滑动操作,可以这样处理
                @SuppressLint("ClickableViewAccessibility")
                @Override
                public boolean onTouchEvent(MotionEvent event) {
                    super.onTouchEvent(event);
                    return true;
                }
            };
            RecyclerView.LayoutParams layoutParams = new RecyclerView.LayoutParams(
                    ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            layoutParams.setMargins(SizeUtils.dp2px(10),SizeUtils.dp2px(5),
                    SizeUtils.dp2px(10),SizeUtils.dp2px(10));
            recyclerView.setLayoutParams(layoutParams);
            final NarrowImageAdapter narrowAdapter;
            recyclerView.setAdapter(narrowAdapter = new NarrowImageAdapter(parent.getContext()));
            recyclerView.setLayoutManager(new LinearLayoutManager(parent.getContext(), LinearLayoutManager.HORIZONTAL,false));
            recyclerView.addItemDecoration(new SpaceViewItemLine(SizeUtils.dp2px(8)));

            narrowAdapter.setMore(R.layout.view_more_horizontal, new RecyclerArrayAdapter.OnLoadMoreListener() {
                @Override
                public void onLoadMore() {
                    new Handler().postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            ToastUtils.showRoundRectToast("没有更多呢!");
                        }
                    },1000);
                }
            });
            List<VideoPlayerFavorite> favoriteList = new ArrayList<>();
            for(int a=0 ; a<10 ; a++){
                VideoPlayerFavorite videoPlayerFavorite = new VideoPlayerFavorite(
                        "这个是猜你喜欢的标题",R.drawable.bg_small_tree_min,"");
                favoriteList.add(videoPlayerFavorite);

            }
            narrowAdapter.addAll(favoriteList);
            return recyclerView;
        }

        @Override
        public void onBindView(View headerView) {
            //这里的处理别忘了
            ((ViewGroup)headerView).requestDisallowInterceptTouchEvent(true);
        }
    });
}
 
Example #29
Source File: EasyPopActivity.java    From EasyPopup with Apache License 2.0 4 votes vote down vote up
private void showQQPop(View view) {
    int offsetX = SizeUtils.dp2px(20) - view.getWidth() / 2;
    int offsetY = (mTitleBar.getHeight() - view.getHeight()) / 2;
    mQQPop.showAtAnchorView(view, YGravity.BELOW, XGravity.ALIGN_RIGHT, offsetX, offsetY);
}
 
Example #30
Source File: InnovationFragment.java    From YCAudioPlayer with Apache License 2.0 4 votes vote down vote up
@SuppressLint("ResourceType")
private LinearLayout initFiveButtonView() {
    ArrayList<String> title = new ArrayList<>();
    title.add("视频");
    title.add("图片");
    title.add("压缩包");
    title.add("文档");
    title.add("其他");
    //四个按钮
    LinearLayout btnLinearLayout = new LinearLayout(activity);
    LinearLayout.LayoutParams params = new
            LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    btnLinearLayout.setLayoutParams(params);
    btnLinearLayout.setPadding(0, SizeUtils.dp2px(15), 0, SizeUtils.dp2px(15));
    btnLinearLayout.setOrientation(LinearLayout.HORIZONTAL);
    //重点:根据服务器返回数据动态创建按钮。如果返回5条数据,就创建5个按钮
    for (int i = 0; i < 5; i++) {
        LinearLayout llBtn = new LinearLayout(activity);
        LinearLayout.LayoutParams llLayoutParams = new
                LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        llLayoutParams.width = 0;
        llLayoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT;
        llLayoutParams.weight = 1;
        llLayoutParams.gravity = Gravity.CENTER;
        llBtn.setLayoutParams(llLayoutParams);
        llBtn.setOrientation(LinearLayout.VERTICAL);
        llBtn.setId(1000 + i);
        llBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AppLogUtils.e("onClick"+v.getId());
                switch (v.getId()) {
                    case 1000:
                        ActivityUtils.startActivity(LocalVideoActivity.class);
                        break;
                    case 1001:
                        ActivityUtils.startActivity(LocalOfficeActivity.class);
                        break;
                    case 1002:
                        ActivityUtils.startActivity(LocalZipFileActivity.class);
                        break;
                    case 1003:
                        ActivityUtils.startActivity(DetailVideoActivity.class);
                        break;
                    case 1004:
                        ActivityUtils.startActivity(DetailVideoActivity.class);
                        break;
                    default:
                        break;
                }
            }
        });

        ImageView imageView = new ImageView(activity);
        LinearLayout.LayoutParams ivLayoutParams = new LinearLayout.LayoutParams(SizeUtils.dp2px(45), SizeUtils.dp2px(45));
        ivLayoutParams.gravity = Gravity.CENTER;
        imageView.setLayoutParams(ivLayoutParams);
        ImageUtil.loadImgByPicasso(activity, R.drawable.ic_home_first, imageView);

        TextView textView = new TextView(activity);
        LinearLayout.LayoutParams tvLayoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        tvLayoutParams.topMargin = SizeUtils.dp2px(8);
        tvLayoutParams.gravity = Gravity.CENTER;
        textView.setLayoutParams(tvLayoutParams);
        textView.setTextSize(14);
        textView.setText(title.get(i));
        llBtn.addView(imageView);
        llBtn.addView(textView);
        btnLinearLayout.addView(llBtn);
    }
    return btnLinearLayout;
}