2

I have RecyclerView with Horizontal scroll inside a fragment. There are TextView and ListView Inside the RecyclerView.

The ListView height is not matching the parent Height as expected.

This is how it looks:

enter image description here

Layout Bound Screenshot

This list Recycler View Layout.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginEnd="10dp"
    android:orientation="vertical">

    <TextView
        android:id="@+id/id_DateTime"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="13/03/2019 - 6.30 PM"
        android:textAlignment="center"
        android:textStyle="bold" />

    <ListView
        android:id="@+id/id_ListView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:divider="@color/browser_actions_title_color"
        android:dividerHeight="1dp"
        android:isScrollContainer="true" />

</LinearLayout>

And My Adapter class file:

@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
    cardview_Listview cardview_listview = cardview_listviews.get(position);
    holder.tv_DateTime.setText(cardview_listview.getS_DateTime());
    holder.setListView(cardview_listview.getS_EntryList());
}

@Override
public int getItemCount() {
    return cardview_listviews.size();
}    
public class ViewHolder extends RecyclerView.ViewHolder {

    TextView tv_DateTime;
    ListView listView;

    ViewHolder(@NonNull View itemView) {
        super(itemView);
        tv_DateTime = itemView.findViewById(R.id.id_DateTime);
        listView = itemView.findViewById(R.id.id_ListView);
    }

    void setListView(List<String> s_entryList) {
        ArrayAdapter<String> adapter = new ArrayAdapter<>(context,
                android.R.layout.simple_list_item_1, s_entryList);
        listView.setAdapter(adapter);
    }
}

I have tried some threads but none worked:

This my test app which I tried and got what I expected:
3

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Vignesh
  • 355
  • 1
  • 4
  • 17

2 Answers2

0

Maybe you should set your LinearLayout height and width to match_parent.

Amine
  • 2,241
  • 2
  • 19
  • 41
  • Can you tell me what do you expect as a result ? – Amine Apr 01 '19 at 13:23
  • Take a look at your fragment container size – Amine Apr 01 '19 at 13:24
  • even though i set width match parent and height wrap content except for the ListView and the other way still same result. – Vignesh Apr 01 '19 at 13:30
  • i have update the thread please take a look at the screenshot – Vignesh Apr 01 '19 at 13:31
  • When I saw your desired results I started thinking about maybe your recyclerView is displaying only the first item. – Amine Apr 01 '19 at 13:36
  • yes eve i thought that too but the list view shows small scrollbar which is clearly visible in the first column and i even went ahead and checked the size of the list i shows correctly as 17 which is the queue which is expected. – Vignesh Apr 01 '19 at 13:39
  • hmmm i am sorry this is the Commercial application so i can not show the codes. – Vignesh Apr 01 '19 at 13:51
0

Well, removing layout_marginEnd will work

Saurav Kumar
  • 891
  • 8
  • 14