android– 如何在水平RecyclerView下添加点?

android– 如何在水平RecyclerView下添加点?,第1张

概述我有RecyclerView,可以显示我想要的图像RecyclerViewdetailsRecycleImage=(RecyclerView)view.findViewById(R.id.detailsRcycleImage);RecyclerView.LayoutManagermLayoutManager=newLinearLayoutManager(getActivity().getApplicationContext(),

我有RecyclerVIEw,可以显示我想要的图像

    RecyclerVIEw detailsRecycleImage = (RecyclerVIEw) vIEw.findVIEwByID(R.ID.detailsRcycleImage);     RecyclerVIEw.LayoutManager mLayoutManager = new linearlayoutmanager(      getActivity().getApplicationContext(),      linearlayoutmanager.HORIZONTAL,      false    );    detailsRecycleImage.setLayoutManager(mLayoutManager);    ImagesAdapter imgAdapter = new     ImagesAdapter(getActivity(),contactsData.getContactimages());    detailsRecycleImage.setAdapter(imgAdapter);  

我的适配器代码是

     public class ImagesAdapter extends  RecyclerVIEw.Adapter<ImagesAdapter.MyVIEwHolder>{  private Context cnt;  public ArrayList<String> imgsUrls;  public ImagesAdapter(Context cnt, ArrayList<String> imgsUrls) {    this.cnt=cnt;    this.imgsUrls=imgsUrls;  }  @OverrIDe  public MyVIEwHolder onCreateVIEwHolder(VIEwGroup parent, int vIEwType) {    VIEw itemVIEw = LayoutInflater.from(parent.getContext()).inflate(R.layout.single_img,parent,false);    return new MyVIEwHolder(itemVIEw);  }  @OverrIDe  public voID onBindVIEwHolder(final MyVIEwHolder holder, int position) {    String singleimg = imgsUrls.get(position);    Picasso.with(cnt).load(singleimg).into(holder.img);  }  @OverrIDe  public int getItemCount() {    return imgsUrls.size();  }  public class MyVIEwHolder extends RecyclerVIEw.VIEwHolder {    public ImageVIEw img;    public MyVIEwHolder(VIEw vIEw) {      super(vIEw);      img = (ImageVIEw) vIEw.findVIEwByID(R.ID.img);    }  }}

我的布局是

<relativeLayout xmlns:androID="@R_301_6822@://schemas.androID.com/apk/res/androID"    androID:layout_wIDth="match_parent"    androID:layout_height="wrap_content">        <ImageVIEw          androID:layout_wIDth="match_parent"          androID:layout_height="wrap_content"          androID:ID="@+ID/img"          /></relativeLay

我只需要在recyclervIEw下添加点作为此图像的指示符
   



有没有办法在我的代码中添加一些内容并获得此视图?

解决方法:

看一下这个:
https://blog.davidmedenjak.com/android/2017/06/24/viewpager-recyclerview.html

Tldr:
创建一个LinePagerIndicatorDecoration并将其添加到我们的RecyclerVIEw:

// pager indicatorrecyclerVIEw.addItemdecoration(new linePagerIndicatordecoration());
总结

以上是内存溢出为你收集整理的android – 如何在水平RecyclerView下添加点?全部内容,希望文章能够帮你解决android – 如何在水平RecyclerView下添加点?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:http://outofmemory.cn/web/1116670.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-29
下一篇2022-05-29

发表评论

登录后才能评论

评论列表(0条)

    保存