2017-03-09 43 views
0

enter image description here如何切換回收站的創建方向查看

嗨,我有一個問題。

我想從左側創建recyclerview的項目。但他們目前是正確的。

你能給我一點提示嗎?

所有的佈局設置已經是「水平」

感謝您閱讀我的問題。

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="50dp" 
    android:orientation="horizontal"> 
    <android.support.v7.widget.RecyclerView 
     android:id="@+id/recycle_view" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:scrollbars="horizontal" 
     android:layout_gravity="left" 
     > 

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

public class PostAdapter extends RecyclerView.Adapter<Bitmap_ViewHolder> { 

    private ArrayList<Bitmap> items=new ArrayList<>(); 

    public PostAdapter(ArrayList<Bitmap> items){ 
     this.items=items; 
    } 

    //뷰홀더 객체 생성 
    @Override 
    public Bitmap_ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 
     View v=LayoutInflater.from(parent.getContext()).inflate(R.layout.add_imagelist,parent,false); 
     return new Bitmap_ViewHolder(v); 
    } 

    // 데이터를 뷰홀더와 바인딩 
    @Override 
    public void onBindViewHolder(Bitmap_ViewHolder holder, int position) { 
     Bitmap item=items.get(position); 
     holder.iv.setImageBitmap(item); 
    } 

    // 추가 
    public void add(Bitmap pd){ 
     items.add(pd); 
     notifyDataSetChanged(); 
    } 

    // 특정 위치 아이템 삭제 
    public void removeItem(PostData pd, int index){ 
     items.remove(index); 
     notifyItemRemoved(index); 
    } 

    public ArrayList<Bitmap> getAllItem(){ 
     return items; 
    } 

    //데이타 수 
    @Override 
    public int getItemCount() { 
     return items.size(); 
    } 
} 


public class Bitmap_ViewHolder extends RecyclerView.ViewHolder { 
    ImageView iv; 
    public Bitmap_ViewHolder(View v){ 
     super(v); 
     iv=(ImageView)v.findViewById(R.id.addlist_picture); 
    } 
} 






@Override 
public void onClick(View v) { 
    switch (v.getId()){ 
     //사진 추가 눌렸을 때 
     case R.id.iv_picture: 
      openGallery(); 
      break; 
     case R.id.tv_picture: 
      openGallery(); 
      break; 


private void openGallery(){ 
    Intent gallery=new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.INTERNAL_CONTENT_URI); 
    startActivityForResult(gallery, PICK_IMAGE); 
} 

private void init(){ 
    item= new ArrayList<>(); 
    mAdapter=new PostAdapter(item); 
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, true)); 
    mRecyclerView.setAdapter(mAdapter); 
} 

回答

0

我解決了這個問題。

我只是設置了。

<android.support.v7.widget.RecyclerView 
        android:id="@+id/recycle_view" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:scrollbars="horizontal" 
        > 
       </android.support.v7.widget.RecyclerView> 

Formerl,我將View的寬度和高度設置爲'match_parent'。因此,每個項目顯示爲佔用更大的鏡頭,即使它們只設置了60dp。

這是我非常愚蠢的失誤。