私はこの効果メイクの幅が画面幅の70%
[![Design image][1]][1]
[1]: http://i.stack.imgur.com/SCMA5.jpg
を作成しようとしていますが、各カードには、幅の100%であるということです画面は70%になる。ここで
は、ここで、各項目のXMLコード
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_margin="@dimen/scale_20dp"
android:id="@+id/rowLayout"
>
<LinearLayout
android:id="@+id/button_parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/card_view"
>
<LinearLayout
android:id="@+id/currentYear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/paymentscreengrey"
android:orientation="vertical"
android:layout_gravity="center"
android:gravity="center"
android:paddingTop="@dimen/scale_50dp"
android:paddingLeft="35dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="**** **** **** 5432"
android:textSize="@dimen/scale_20dp"
android:textColor="@color/white"
android:layout_marginTop="@dimen/scale_20dp"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="2345"
android:textSize="@dimen/scale_16dp"
android:textColor="@color/white" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:paddingRight="@dimen/scale_20dp"
android:paddingTop="@dimen/scale_15dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="PERSONAL"
android:fontFamily="bold"
android:textColor="@color/white"
android:textSize="18dp"
android:textStyle="bold" />
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/title_valid_up_to"
android:textColor="@color/white"
android:textSize="10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="12/15"
android:layout_marginLeft="10dp"
android:textColor="@color/white"
android:textSize="@dimen/text_18"
/>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</LinearLayout>
あるリサイクルビューに実際にこれを行うの
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/rv"
/>
</LinearLayout>
and finally the recycler view
package com.heyjude.heyjudeapp.adapter;
import android.app.Activity;
import android.graphics.Point;
import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import com.heyjude.heyjudeapp.R;
import com.heyjude.heyjudeapp.model.Card;
import java.util.ArrayList;
import java.util.List;
public class CheckOutCardRecycler extends RecyclerView.Adapter<CheckOutCardRecycler.CardViewHolder>{
private List<Card> checkOutCard;
private int screenWidth;
public CheckOutCardRecycler(Activity activity, List<Card> checkOutCard){
Display display = activity.getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
this.screenWidth = size.x;
this.checkOutCard = checkOutCard;
}
public static class CardViewHolder extends RecyclerView.ViewHolder {
CardView card;
LinearLayout row;
CardViewHolder(View itemView) {
super(itemView);
row = (LinearLayout)itemView.findViewById(R.id.rowLayout);
card = (CardView)itemView.findViewById(R.id.card_view);
}
}
@Override
public int getItemCount() {
return checkOutCard.size();
}
@Override
public CardViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.row_checkout_cards, viewGroup, false);
CardViewHolder pvh = new CardViewHolder(v);
return pvh;
}
@Override
public void onBindViewHolder(CardViewHolder cardViewHolder, int i) {
}
@Override
public void onAttachedToRecyclerView(Recycler View recyclerView) {
super.onAttachedToRecyclerView(recyclerView);
}
}
の代わりに、リサイクルビューあなたは、デフォルトで必要と、この機能を持つビューページャを使用することができます[これを参照してください](http://stackoverflow.com/questions/9907748/viewpager-get-a-next-page-of-the-next-page) – SaravInfern
項目を動的にビューページに追加できますか? –
はい、ビューのページャを動的に追加/削除することができます – SaravInfern