MagicIndicator icon indicating copy to clipboard operation
MagicIndicator copied to clipboard

CommonNavigatorAdapter.getTitleView中imageView不显示网络图片,使用静态资源可正常显示

Open AnneWei opened this issue 7 years ago • 0 comments

CommonNavigator commonNavigator = new CommonNavigator(getContext()); commonNavigator.setFollowTouch(true);

    commonNavigator.setScrollPivotX(0.5f);
    commonNavigator.setEnablePivotScroll(true);
    commonNavigator.setRightPadding(50);
    commonNavigator.setAdapter(
            new CommonNavigatorAdapter() {
                @Override
                public int getCount() {
                    return products == null ? 0 : products.size();
                }

                @Override
                public IPagerTitleView getTitleView(Context context, int index) {
                    CommonPagerTitleView commonPagerTitleView =
                            new CommonPagerTitleView(context);
                    commonPagerTitleView.setContentView(
                            R.layout.app_usercomment_indicator_layout);
                    TextView textView = commonPagerTitleView.findViewById(
                            R.id.user_comment_app_name_textView);
                    UrlImageView imageView = commonPagerTitleView.findViewById(
                            R.id.user_comment_app_icon_imageView);
                    // 设置产品名称
                    textView.setText(products.get(index).getProduct_name());
                    textView.setTextSize(10);
                    // 产品icon加载url资源

// imageView.setBackgroundResource(R.drawable.shoubai); Log.d(TAG, products.get(index).getProduct_img());

                    Glide.with(imageView)
                            .load("https://avatar.csdnimg.cn/2/1/A/1_fitaotao.jpg")
                            .centerCrop().placeholder(R.drawable.ic_launcher_background)
                            .error(R.drawable.ic_launcher_foreground).into(imageView);

                    commonPagerTitleView.setOnPagerTitleChangeListener(
                            new CommonPagerTitleView.OnPagerTitleChangeListener() {
                                @Override
                                public void onSelected(int index, int totalCount) {
                                    textView.setTextColor(Color.BLACK);
                                    textView.setTextSize(11);
                                }

                                @Override
                                public void onDeselected(int index, int totalCount) {
                                    textView.setTextColor(Color.GRAY);
                                    textView.setTextSize(10);
                                }

                                @Override
                                public void onLeave(int index, int totalCount, float leavePercent,
                                                    boolean leftToRight) {

// imageView.setScaleX(1.2f + (1f - 1.2f)); // imageView.setScaleY(1.2f + (1f - 1.2f)); }

                                @Override
                                public void onEnter(int index, int totalCount, float enterPercent,
                                                    boolean leftToRight) {

// imageView.setScaleX(1f + (1.2f - 1f)); // imageView.setScaleY(1f + (1.2f - 1f)); } }); commonPagerTitleView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { viewPager.setCurrentItem(index); } }); return commonPagerTitleView;

                }

                @Override
                public IPagerIndicator getIndicator(Context context) {
                    // 设置标题指示器,也有多种,可不选,即没有标题指示器。
                    BezierPagerIndicator indicator = new BezierPagerIndicator(context);
                    indicator.setColors(Color.parseColor("#ff4a42")
                            , Color.parseColor("#fcde64"), Color.parseColor("#73e8f4")
                            , Color.parseColor("#76b0ff"), Color.parseColor("#c683fe")
                            , Color.parseColor("#76b0ff"), Color.parseColor("#c683fe")
                            , Color.parseColor("#76b0ff"), Color.parseColor("#c683fe"));
                    indicator.setHorizontalScrollBarEnabled(true);

                    return indicator;
                }
            }
    );

AnneWei avatar Jul 10 '19 14:07 AnneWei