Здравствуйте,почему карточки с image создаются не рядом,а всегда в самом начале?Использую recycler,cardview,picasso.
public class Home extends Fragment {
private ArrayList<String> imageurl = new ArrayList<>();
private RecyclerView recyclerView;
@Nullable
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View rootView =inflater.inflate(R.layout.homefragment, container, false);
recyclerView=rootView.findViewById(R.id.recyclerhome);
getImages();
return rootView;
}
private void getImages(){
imageurl.add("https://pp.userapi.com/c639616/v639616425/47bd3/iqmvzRCNBm4.jpg");
imageurl.add("https://pp.userapi.com/c639616/v639616425/47bd3/iqmvzRCNBm4.jpg");
initRecyclerView();
}
private void initRecyclerView(){
LinearLayoutManager layoutManager=new LinearLayoutManager(getContext(),LinearLayoutManager.HORIZONTAL,false);
recyclerView.setLayoutManager(layoutManager);
RecyclerPopAdapter popAdapter= new RecyclerPopAdapter(imageurl,getContext());
recyclerView.setAdapter(popAdapter);
}
}
public class RecyclerPopAdapter extends RecyclerView.Adapter<RecyclerPopAdapter.ViewHolder> {
private static final String TAG= "RecyclerPopAdapter";
private ArrayList<String> image = new ArrayList<>();
private Context context;
RecyclerPopAdapter(ArrayList<String> image, Context context) {
this.image= image;
this.context = context;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
Log.d(TAG,"onCreateViewHolder: called.");
View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.card_popul,parent,false);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
Log.d(TAG,"onBindViewHolder: called.");
Picasso.with(context).load(image.get(position)).into(holder.image);
holder.image.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
}
});
}
@Override
public int getItemCount() {
return image.size();
}
class ViewHolder extends RecyclerView.ViewHolder{
ImageView image;
ViewHolder(View itemView) {
super(itemView);
image= itemView.findViewById(R.id.imagepopul);
}
}
}