tôi sử dụng RecyclerView theo hướng nằm ngang và phần tử mới là trái sang phải. và cuộn là ltr. làm thế nào để thay đổi hướng này?RecyclerView Phát triển phần tử từ phải sang trái
Xml Code:
<android.support.v7.widget.RecyclerView
android:id="@+id/rc3"
android:layout_gravity="right"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
Và Java:
RecyclerView rc1 = (RecyclerView) findViewById(R.id.rc1);
AdapterMainPrice mainPrice = new AdapterMainPrice(StructPrice.getThreePrice());
rc1.setHasFixedSize(false);
LinearLayoutManager llm = new LinearLayoutManager(G.context);
llm.setOrientation(LinearLayoutManager.HORIZONTAL);
rc1.setLayoutManager(llm);
rc1.setAdapter(mainPrice);
Adaptor:
public class AdapterMainPrice kéo dài RecyclerView.Adapter {
private List<StructPrice> prices;
public AdapterMainPrice(List<StructPrice> catList) {
this.prices = catList;
}
@Override
public int getItemCount() {
return prices.size();
}
@Override
public void onBindViewHolder(NewsViewHolder ghazaViewHolder, int position) {
StructPrice price = prices.get(position);
ghazaViewHolder.vTitle.setText(price.getProductName());
Glide.with(G.context)
.load(price.getProductPic())
.placeholder(R.drawable.loading_spinner)
.crossFade()
.into(ghazaViewHolder.Vimg);
ghazaViewHolder.cardView.startAnimation(ghazaViewHolder.animation);
}
@Override
public NewsViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
View itemView = LayoutInflater.
from(viewGroup.getContext()).
inflate(R.layout.adapter_item_main, viewGroup, false);
return new NewsViewHolder(itemView);
}
public static class NewsViewHolder extends RecyclerView.ViewHolder {
protected TextView vTitle;
protected ImageView Vimg;
protected Animation animation;
protected CardView cardView;
public NewsViewHolder(View v) {
super(v);
vTitle = (TextView) v.findViewById(R.id.mainRCtv);
Vimg = (ImageView) v.findViewById(R.id.mainRCimg);
animation = AnimationUtils.loadAnimation(G.context, R.anim.fadein);
cardView = (CardView) v.findViewById(R.id.mainRCCard);
}
}
Có thể trùng lặp [Làm cách nào tôi có thể điền vào RecyclerView với GridLayoutManager từ phải sang trái] (http://stackoverflow.com/questions/32920867/how-can-i-fill-recyclerview-with-gridlayoutmanager-from-right- sang trái) –