2017-03-09 1 views
0

enter image description hererecyclerView에서 생성 방향을 전환하는 방법

안녕하세요, 저는 약간의 질문이 있습니다.

왼쪽에서 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> 

이전 버전에서는 View의 너비와 높이를 'match_parent'로 설정했습니다. 따라서 각 항목은 60dp 만 설정하는 경우에도 더 큰 scrren을 차지하는 것으로 표시됩니다.

그건 내 바보 miskate.

관련 문제