0

I have tested all i can from google, so. In the picture there are more wrong answers list which should be shown, but it's not showing.

enter image description here

I tried, 30dp or more bottompadding to listview , android:layout_marginBottom="?attr/actionBarSize" , app:layout_behavior="@string/appbar_scrolling_view_behavior" , adding listview in scrollview etc, but nothing is solving this problem. Please suggest something !

xml file

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.it.jumtech.adaptest.activity.ResultDetailActivity">

<TextView
    android:id="@+id/textView2"
    android:layout_width="250dp"
    android:layout_height="wrap_content"
    android:layout_marginLeft="25dp"
    android:text="Result Detail"
    android:textColor="@android:color/holo_orange_dark"
    android:textSize="24sp"
    android:textStyle="bold"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    android:layout_marginTop="16dp"
    android:layout_marginStart="25dp" />

<TextView
    android:id="@+id/tv_name"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="25dp"
    app:layout_constraintLeft_toLeftOf="parent"
    android:layout_marginTop="8dp"
    android:textSize="16sp"
    app:layout_constraintTop_toBottomOf="@+id/textView2"
    android:layout_marginStart="25dp" />
<TextView
    android:id="@+id/tv_roll"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="16sp"
    android:layout_marginLeft="25dp"
    app:layout_constraintLeft_toLeftOf="parent"
    android:layout_marginTop="8dp"
    app:layout_constraintTop_toBottomOf="@+id/tv_name"
    android:layout_marginStart="25dp" />

<TextView
    android:id="@+id/label1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="25dp"
    android:layout_marginStart="25dp"
    android:layout_marginTop="8dp"
    android:text="Correct Answers"
    android:textSize="16sp"
    android:textColor="@android:color/holo_blue_light"
    android:textStyle="bold"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/tv_wrongscore" />
<ListView
    android:id="@+id/lv_rightlist"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    tools:layout_editor_absoluteY="205dp"
    tools:layout_editor_absoluteX="8dp"
    app:layout_constraintLeft_toLeftOf="parent"
    android:paddingBottom="10dp"
    app:layout_constraintTop_toBottomOf="@+id/label1"/>
<TextView
    android:id="@+id/label2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Wrong Answers"
    android:textSize="16sp"
    android:layout_marginLeft="25dp"
    android:textStyle="bold"
    app:layout_constraintLeft_toLeftOf="parent"
    android:textColor="@android:color/holo_blue_light"
    android:layout_marginTop="8dp"
    app:layout_constraintTop_toBottomOf="@+id/lv_rightlist"
    android:layout_marginStart="25dp" />
<ListView
    android:id="@+id/lv_wronglist"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    tools:layout_editor_absoluteY="205dp"
    tools:layout_editor_absoluteX="8dp"
    app:layout_constraintLeft_toLeftOf="parent"
    android:paddingBottom="40dp"
    app:layout_constraintTop_toBottomOf="@+id/label2"/>

</android.support.constraint.ConstraintLayout>

list resource file

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.it.jumtech.adaptest.activity.ResultDetailActivity">

<TextView
    android:id="@+id/tv_qsn"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="18sp"
    android:layout_marginLeft="8dp"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    android:layout_marginTop="8dp" />
<TextView
    android:id="@+id/label1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Answer "
    android:textSize="16sp"
    android:layout_marginLeft="8dp"
    app:layout_constraintTop_toBottomOf="@+id/tv_qsn"
    app:layout_constraintLeft_toLeftOf="parent"
    android:layout_marginTop="8dp" />
<TextView
    android:id="@+id/tv_asnwer"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="16sp"
    android:textColor="#000000"
    android:layout_marginLeft="0dp"
    app:layout_constraintLeft_toRightOf="@+id/label1"
    app:layout_constraintTop_toBottomOf="@+id/tv_qsn"
    android:layout_marginTop="8dp" />
<TextView
android:id="@+id/label2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Choosen "
android:textSize="16sp"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toRightOf="@+id/tv_asnwer"
app:layout_constraintTop_toBottomOf="@+id/tv_qsn"
android:layout_marginTop="8dp" />
<TextView
    android:id="@+id/tv_choosen"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="16sp"
    android:textColor="#000000"
    android:layout_marginLeft="0dp"
    app:layout_constraintLeft_toRightOf="@+id/label2"
    app:layout_constraintTop_toBottomOf="@+id/tv_qsn"
    android:layout_marginTop="8dp" />
<TextView
    android:id="@+id/label3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Mark "
    android:textSize="16sp"
    android:layout_marginLeft="8dp"
    app:layout_constraintLeft_toRightOf="@+id/tv_choosen"
    app:layout_constraintTop_toBottomOf="@+id/tv_qsn"
    android:layout_marginTop="8dp" />
<TextView
    android:id="@+id/tv_mark"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="16sp"
    android:textColor="#000000"
    android:layout_marginLeft="0dp"
    app:layout_constraintLeft_toRightOf="@+id/label3"
    app:layout_constraintTop_toBottomOf="@+id/tv_qsn"
    android:layout_marginTop="8dp" />

user3099225
  • 413
  • 1
  • 4
  • 14

2 Answers2

0

If you are using two list view in one layout than you need to calculate list height programmatically and set to lists. For this, answer at this link can be helpful

PJain
  • 526
  • 2
  • 14
0

The approach you are following is incorrect. To design such kind of view, you should create a nested RecyclerView. Inside the parent RecyclerView view, you should create another recyclerView. So the adapter of parent RecyclerView will have a child recyclerView. In the adapter class, you can inflate different view types based upon your requirement. Below is the dummy code for parent Adapter class for your help.

@NonNull
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        LayoutInflater inflater = LayoutInflater.from(parent.getContext());
        View view;
        switch (viewType) {
            case TYPE1:
                view = inflater.inflate(R.layout.layout_1, parent, false);
                return new ViewHolder1(view);
            case TYPE_DATA:
                view = inflater.inflate(R.layout.layout_2, parent, false);
                return new Viewholder2(view);

            default:
                throw new RuntimeException("No match for found for" + viewType);
        }
    }



@Override
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
        if (holder instanceof Viewholder1) {
            viewholder1 = (Viewholder1) holder;
          }
        if (holder instanceof Viewholder2) {
            viewholder2 = (Viewholder2) holder;
        }
    }


    @Override
            public int getItemViewType(int position) {
                //Based on certain condition, change your return type
               if (type1)
                 return viewType1;
               if(type2)
                 return viewType2;
                 ....        
}
Apurv
  • 391
  • 2
  • 9