java.lang.IllegalStateException: Content View height is too small
altaf2892 opened this issue · 4 comments
** i have added this to my project and implemented it with recyclerview**
error generate when i click on itemview
mainxml is pendingrequest_item.xml
`
<com.ramotion.foldingcell.FoldingCell xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:folding-cell="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
folding-cell:additionalFlipsCount="2"
folding-cell:animationDuration="1300"
folding-cell:backSideColor="@color/bgBackSideColor"
folding-cell:cameraHeight="30">
<include layout="@layout/pending_titleview" />
<include layout="@layout/pendingrequest_detail" />
</com.ramotion.foldingcell.FoldingCell>`
contentview.xml
`
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbarThumbVertical="@android:color/transparent"
android:scrollbars="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/linear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="@+id/car_image"
android:layout_width="match_parent"
android:layout_height="170dp"
android:rotation="0"
android:scaleType="centerInside"
android:src="@drawable/car" />
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:text="TexiGO"
android:textColor="@color/black" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Affordable,everyday rides"
android:textColor="@color/black"
android:textStyle="bold" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="1dp"
android:background="@color/liner" />
</LinearLayout>
<LinearLayout
android:id="@+id/linear_child1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/linear"
android:layout_marginTop="5dp"
android:gravity="center_horizontal"
android:orientation="vertical">
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableRow
android:id="@+id/capacity_row"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:padding="10dp">
<TextView
android:id="@+id/capacity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Capacity "
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/txt_capacity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="1-4 Persons"
android:textAppearance="?android:attr/textAppearanceSmall" />
</TableRow>
<TableRow
android:id="@+id/basefare_row"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:padding="10dp">
<TextView
android:id="@+id/basefare"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Base Fare "
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/txt_basefare"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="5 $"
android:textAppearance="?android:attr/textAppearanceSmall" />
</TableRow>
<TableRow
android:id="@+id/pickuplocation_row"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:padding="10dp">
<TextView
android:id="@+id/pickuplocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pickup Location "
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/txt_pickuplocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="2"
android:text="W90th ,Newyork ,NY 10025"
android:textAppearance="?android:attr/textAppearanceSmall" />
</TableRow>
<TableRow
android:id="@+id/droplocation_row"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:padding="10dp">
<TextView
android:id="@+id/droplocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Drop Location "
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/txt_droplocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="2"
android:text="46th Ave,Woodside Ny 11101"
android:textAppearance="?android:attr/textAppearanceSmall" />
</TableRow>
<TableRow
android:id="@+id/name_row"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:padding="10dp">
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name "
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/txt_drivername"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="John Doe"
android:textAppearance="?android:attr/textAppearanceSmall" />
</TableRow>
<TableRow
android:id="@+id/mobilenumber_row"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:padding="10dp">
<TextView
android:id="@+id/mobilenumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mobile Number "
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/txt_mobilenumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="+919924580789"
android:textAppearance="?android:attr/textAppearanceSmall" />
</TableRow>
<TableRow
android:id="@+id/paymentstatus_row"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:padding="10dp">
<TextView
android:id="@+id/paymentstatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Payment Status "
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/txt_paymentstatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="NO STATUS"
android:textAppearance="?android:attr/textAppearanceSmall" />
</TableRow>
</TableLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#DDE4E8" />
<!--
<android.support.v7.widget.AppCompatButton
android:id="@+id/btn_accept"
style="@style/Base.TextAppearance.AppCompat.Widget.Button.Borderless.Colored"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/linear_child1"
android:layout_marginBottom="@dimen/detail_bottom_margin"
android:layout_marginTop="@dimen/detail_bottom_margin"
android:background="@drawable/detail_button"
android:text="ACCEPT" />
<android.support.v7.widget.AppCompatButton
android:id="@+id/btn_cancel"
style="@style/Base.TextAppearance.AppCompat.Widget.Button.Borderless.Colored"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/linear_child1"
android:layout_marginBottom="@dimen/detail_bottom_margin"
android:layout_marginTop="@dimen/detail_bottom_margin"
android:background="@drawable/detail_button"
android:text="CANCEL" />-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/detail_bottom_margin"
android:orientation="horizontal"
android:weightSum="2">
<android.support.v7.widget.AppCompatButton
android:id="@+id/btn_accept"
style="@style/Base.TextAppearance.AppCompat.Widget.Button.Borderless.Colored"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/linear_child1"
android:layout_marginEnd="@dimen/five_dp"
android:layout_marginRight="@dimen/five_dp"
android:layout_weight="1"
android:background="@drawable/ripple_effect"
android:text="ACCEPT" />
<android.support.v7.widget.AppCompatButton
android:id="@+id/btn_cancel"
style="@style/Base.TextAppearance.AppCompat.Widget.Button.Borderless.Colored"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/linear_child1"
android:layout_marginBottom="@dimen/detail_bottom_margin"
android:layout_marginLeft="@dimen/five_dp"
android:layout_marginStart="@dimen/five_dp"
android:layout_weight="1"
android:background="@drawable/ripple_effect"
android:text="CANCEL" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</ScrollView>
<android.support.v7.widget.CardView
android:id="@+id/cardView"
app:cardBackgroundColor="@color/colorPrimary"
app:cardCornerRadius="10dp"
app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="true"
app:contentPadding="0dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="6dp"
android:background="@color/white">
<RelativeLayout
android:id="@+id/relative_parent"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/five"
android:orientation="horizontal"
android:weightSum="0">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/img_arrow"
android:orientation="vertical">
<TextView
android:id="@+id/from"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="left|start"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:gravity="left|start"
android:text="FROM" />
<TextView
android:id="@+id/txt_from_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_gravity="left|start"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:layout_weight="1"
android:gravity="left|start"
android:maxLines="1"
android:padding="1dp"
android:text="NewYork NY 10025" />
</LinearLayout>
<ImageView
android:id="@+id/img_arrow"
android:layout_width="@dimen/arrow"
android:layout_height="@dimen/arrow"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:layout_marginBottom="@dimen/five_dp"
android:src="@drawable/arrow1" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_toRightOf="@+id/img_arrow"
android:orientation="vertical">
<TextView
android:id="@+id/to"
tools:gravity="right|end"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:gravity="right|end"
android:text="TO" />
<TextView
android:id="@+id/txt_to_add"
tools:gravity="right|end"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1"
android:gravity="right|end"
android:maxLines="1"
android:padding="1dp"
android:text="Wooside NY 11104" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
<View
android:id="@+id/view"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@+id/relative_parent"
android:background="@android:color/darker_gray" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/view"
android:layout_marginTop="@dimen/five"
android:orientation="horizontal"
android:weightSum="0">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/img"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/datee"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_gravity="left|start"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:gravity="left|start"
android:padding="1dp"
android:text="DATE" />
<TextView
android:id="@+id/time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_gravity="left|start"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:gravity="left|start"
android:padding="1dp"
android:text="TIME"
android:textStyle="bold" />
</LinearLayout>
<TextView
android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_gravity="left|start"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:gravity="left|start"
android:padding="1dp"
android:text="March 7th,2017" />
</LinearLayout>
<View
android:id="@+id/img"
android:layout_width="@dimen/arrow"
android:layout_height="@dimen/arrow"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:padding="@dimen/five"
android:src="@drawable/arrow1" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_toRightOf="@+id/img"
android:orientation="vertical">
<TextView
android:id="@+id/drivername"
tools:gravity="right|end"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:gravity="right|end"
android:padding="1dp"
android:text="CUSTOMER NAME" />
<TextView
tools:gravity="right|end"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:gravity="right|end"
android:padding="1dp"
android:text="CUSTOMER NAME"
android:visibility="invisible" />
<TextView
android:id="@+id/txt_drivername"
tools:gravity="right|end"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:layout_toRightOf="@+id/date"
android:gravity="right|end"
android:padding="1dp"
android:text="John Doe"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
`
above i have posted three xml file which are as main.xml (to hold items of recyclerview)
pending_titleview is title view which will shown to user at the begining when data gets binded
pendingrequest_detail is the contentview which is not visible to user at the begining and will be shown to user when the user click on
adapter.class
`package "";
public class PendingRequestAdapter extends RecyclerView.Adapter<PendingRequestAdapter.Holder> {
List list;
private HashSet unfoldedIndexes = new HashSet<>();
public PendingRequestAdapter(List<PendingRequestPojo> list) {
this.list = list;
}
@Override
public Holder onCreateViewHolder(ViewGroup parent, int viewType) {
return new Holder(LayoutInflater.from(parent.getContext()).inflate(R.layout.pendingrequest_item, parent, false));
}
@Override
public void onBindViewHolder(Holder holder, final int position) {
final FoldingCell cell = (FoldingCell) holder.itemView;
cell.setTag(holder);
holder.from_add.setText(list.get(holder.getAdapterPosition()).getPickup_adress());
holder.to_add.setText(list.get(holder.getAdapterPosition()).getDrop_address());
holder.drivername.setText(list.get(holder.getAdapterPosition()).getUser_name());
holder.time.setText(CheckConnection.getformattedTime(list.get(holder.getAdapterPosition()).getTime()));
CheckConnection checkConnection = new CheckConnection();
holder.date.setText(checkConnection.getCurrentDateInSpecificFormat(list.get(holder.getAdapterPosition()).getTime()));
//details items setting datas
holder.fare.setText(list.get(position).getAmount() + " $ ");
holder.pickup_location.setText(list.get(holder.getAdapterPosition()).getPickup_adress());
holder.drop_location.setText(list.get(holder.getAdapterPosition()).getDrop_address());
holder.drivername1.setText(list.get(holder.getAdapterPosition()).getUser_name());
holder.mobilenumber.setText(list.get(holder.getAdapterPosition()).getUser_mobile());
if (list.get(holder.getAdapterPosition()).getPayment_status().equals("") || !list.get(holder.getAdapterPosition()).getPayment_status().equals("")) {
holder.payment_status.setText(list.get(holder.getAdapterPosition()).getPayment_status());
} else {
holder.payment_status.setText("UNPAID");
}
if (unfoldedIndexes.contains(position)) {
cell.unfold(true);
} else {
cell.fold(true);
}
holder = (Holder) cell.getTag();
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//((FoldingCell) v).toggle(false);
// register in adapter that state for selected cell is toggled
try {
cell.toggle(false);
registerToggle(position);
} catch (Exception e) {
Log.e("catch", e.toString());
}
}
});
BookFont(holder, holder.f);
BookFont(holder, holder.t);
BookFont(holder, holder.dn);
BookFont(holder, holder.dt);
MediumFont(holder, holder.from_add);
MediumFont(holder, holder.to_add);
MediumFont(holder, holder.date);
}
public void registerToggle(int position) {
if (unfoldedIndexes.contains(position))
registerFold(position);
else
registerUnfold(position);
}
public void registerFold(int position) {
unfoldedIndexes.remove(position);
}
public void registerUnfold(int position) {
unfoldedIndexes.add(position);
}
@Override
public int getItemCount() {
return list.size();
}
public class Holder extends RecyclerView.ViewHolder {
AppCompatButton acceptButton, cancelButton;
TextView t1, t2, t3, t4, t5, faret6 t7;
TextView t8, t9, t10, t11, t12;
TextView f, t, dn, dt;
public Holder(View itemView) {
super(itemView);
////pendinfg details views intializations
t1 = (TextView) itemView.findViewById(R.id.t1);
t2 = (TextView) itemView.findViewById(R.id.t2);
t3 = (TextView) itemView.findViewById(R.id.t3);
t4 = (TextView) itemView.findViewById(R.id.t4);
t5 = (TextView) itemView.findViewById(R.id.t5);
t6 = (TextView) itemView.findViewById(R.id.t6);
t7 = (TextView) itemView.findViewById(R.id.t7);
t8 = (AppCompatButton) itemView.findViewById(R.id.t8);
t9 = (AppCompatButton) itemView.findViewById(R.id.t9);
f = (TextView) itemView.findViewById(R.id.from);
t = (TextView) itemView.findViewById(R.id.to);
dn = (TextView) itemView.findViewById(R.id.drivername);
dt = (TextView) itemView.findViewById(R.id.datee);
t10 = (TextView) itemView.findViewById(R.id.t10);
t11 = (TextView) itemView.findViewById(R.id.t11);
t12 = (TextView) itemView.findViewById(R.id.t12);
t13 = (TextView) itemView.findViewById(R.id.t13);
t14 = (TextView) itemView.findViewById(R.id.t14);
}
}
public void BookFont(Holder holder, TextView view1) {
Typeface font1 = Typeface.createFromAsset(holder.itemView.getContext().getAssets(), "font/font1.otf");
view1.setTypeface(font1);
}
public void MediumFont(Holder holder, TextView view) {
Typeface font = Typeface.createFromAsset(holder.itemView.getContext().getAssets(), "font/font2.otf");
view.setTypeface(font);
}
public interface DetailClick {
void onclick(Bundle bundle);
}
}
`
main class(i set adapter)
PendingRequestAdapter pendingRequestAdapter = new PendingRequestAdapter(list); recyclerView.setAdapter(pendingRequestAdapter); pendingRequestAdapter.notifyDataSetChanged();
Clicking on the open layout is at least as high as the displayed layout,Or you can just give it a fixed value, and I'll do that
can point it out where i have to change?
Content of unfolded state must be at least 2x higher than initial folded state layout, for guarantee at least one fold. You should double check heights of your layouts.
If you don't want animation foldingCell.toggle(true);