0

我想显示一组从Web下载的图像,并将其显示为底部水平缩略图视图的一部分,在水平滚动视图模式下,每当我拍照时,都需要将它添加到列表中底部的图像。如何使用ImageViews实现水平滚动条

什么类型的本地组件被使用,我尝试了回收器视图和horizo​​ntalGridView(LeanBack V17 API,对回收视图的扩展),在它们中,我遇到了水平滚动问题,而我无法修复它出,(scroll issue related to recycle view)

是否有任何其他替代本地API可用于实现图像的水平列表视图。

+0

分享你的'Recyclerview'代码你已经尝试了什么。 – ImMathan

+0

我已经发布在链接http://stackoverflow.com/questions/34333274/regarding-properscrolling-in-horizo​​ntal-recycler-view – Rakesh

回答

0

是的,你可以使用的LinearLayout与属性 android:orientation="horizontal"

你也需要把这个中的LinearLayout以ScrollLayout有滚动过去。

当图像被下载,你可以在ImageView的添加它里面的LinearLayout

0
<android.support.v7.widget.RecyclerView 
    android:id="@+id/recyclerView" 
    android:layout_width="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" 
     android:layout_height="match_parent" 
    > 

    </android.support.v7.widget.RecyclerView> 
    Activity: 

    recyclerView = (RecyclerView) findViewById(R.id.recyclerView); 
     LinearLayoutManager manager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false); 
     recyclerView.setLayoutManager(manager); 
    adapter = new EventListAdapter(this, imageList); 
     recyclerView.setAdapter(adapter); 

    Adapter: 
    public class ImageListAdapter extends RecyclerView.Adapter<ImageListAdapter.ViewHolder> { 


    private final LayoutInflater inflator; 
    private Context context; 
    private List<Integer> imageList = new ArrayList<>(); 

    public ImageListAdapter(Context context, List<Integer> imageList) { 

     this.context = context; 
     this.imageList = imageList; 

     inflator = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
    } 

    @Override 
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 

     View view = inflator.inflate(R.layout.eventlistadapterdata, parent, false); 

     return new ViewHolder(view); 
    } 

    @Override 
    public void onBindViewHolder(ViewHolder holder, int position) { 
     Integer image = imageList.get(position); 

holder.view.setImageResource(image); 
    } 


    @Override 
    public int getItemCount() { 
     return imageList.size(); 
    } 

    static class ViewHolder extends RecyclerView.ViewHolder { 
     ImageView view; 

     ViewHolder(ImageView view) { 
      super(view); 
      this.view = view; 
     } 
    } 


}