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:
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:
- ListView inside ScrollView not Showing all items in the in the Adapter
- Android: RecyclerView not showing List Items in a Fragment
This my test app which I tried and got what I expected: