-2

私は心の中にカードビジョンを持つアプリケーションを開発しようとしています。すべてのビューの端に、あなたは次のカードまたは前のカードを見ることができますどのようにRecyclerViewの表示の実装

お知らせ:私はLinkedInのと同じレイアウトをエミュレートしようとしています。

enter image description hereenter image description here

私はこれはそれの結果であるHorizontal Mode.

RecyclerViewLinearLayoutManagerを使用して同じことを実現しようとしている:

I can only see one card at a time

ここに私のコードは次のとおりです。

profile_card_view.xml(これはRecyclerViewで各カードのレイアウトファイルである)

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <android.support.v7.widget.CardView 
     android:layout_width="match_parent" 
     android:background="#ededed" 
     android:padding="10dp" 
     android:layout_margin="10dp" 
     android:layout_height="match_parent"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:elevation="11dp"> 
    <TextView 
     android:text="Tanishq Sharma" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/profile_name" 
     android:padding="20dp" /> 

    <TextView 
     android:text="I am an entreprenuer, developer." 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/profile_about" 
     android:padding="20dp" /> 

    <TextView 
     android:text="9819075165" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/profile_mobile" 
     android:padding="20dp" /> 

    <TextView 
     android:text="Mumbai" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/profile_location" 
     android:padding="20dp" /> 

     </LinearLayout> 

    </android.support.v7.widget.CardView> 
</LinearLayout> 

Profile_Cards_Adapter.java - アダプタrecyclerView

import android.support.v7.widget.RecyclerView; 
import android.view.LayoutInflater; 
import android.view.View; 
import android.view.ViewGroup; 
import android.widget.TextView; 

import java.util.List; 

/** 
* Created by tanishqsharma on 31/12/16. 
*/ 

public class Profile_Cards_Adapter extends RecyclerView.Adapter<Profile_Cards_Adapter.ViewHolder> { 

    List<Profile_Card> items; 

    public Profile_Cards_Adapter(List<Profile_Card> items) 
    { 
     this.items = items; 
    } 

    @Override 
    public Profile_Cards_Adapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 
     View v = LayoutInflater.from(parent.getContext()) 
       .inflate(R.layout.profile_card_view, parent, false); 
     ViewHolder viewHolder = new ViewHolder(v); 
     return viewHolder; 
    } 

    @Override 
    public void onBindViewHolder(ViewHolder holder, int position) { 

     Profile_Card card = items.get(position); 
     holder.user_name.setText(card.getName()); 
     holder.user_about.setText(card.getAbout()); 
     holder.user_contact.setText(card.getContact()); 
     holder.user_location.setText(card.getLocation()); 
    } 


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

    class ViewHolder extends RecyclerView.ViewHolder{ 

     public TextView user_name; 
     public TextView user_location; 
     public TextView user_about; 
     public TextView user_contact; 
     public ViewHolder(View itemView) { 

      super(itemView); 

      user_name = (TextView) itemView.findViewById(R.id.profile_name); 
      user_about = (TextView) itemView.findViewById(R.id.profile_about); 
      user_contact = (TextView) itemView.findViewById(R.id.profile_mobile); 
      user_location = (TextView) itemView.findViewById(R.id.profile_location); 
     } 
    } 
} 

のための私が取得することができないています私は次と前のカードの端を見ることができるLinkedInのようなレイアウト。

+1

代わりに 'ViewPager'を使用してください。 – AlphaQ

+0

ああ、どんな精巧さも良いだろう。 –

+0

ダウン投票の説明を要求する。 –

答えて

0

コメントに記載されているようにViewPagerを使用する必要があります。それについての詳細はhereをご覧ください。

ヒント:あなたはそれについてアイデアを得るためにあなたが利用できるlibraryがあります。

関連する問題