androidandroid-widget

Last element in ListView in RemoteViews is not fully visible in Android Widgets


I'm trying to show list inside widgets with remoteviews. Scrolling is working fine but last element is not fully scrollable and not fully visible. But if I expand the widget fully it shows the last element.

In my code nothing pretty fancy, just assigning adapter in AppWidgetProvider.

this.setRemoteAdapter(R.id.widgets_list, intent)

My widget_timetable.xml where widget ui stores:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/widget_body_layout"
    style="@style/Widget.AppWidget.AppWidget.Container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/widget_background"
    android:orientation="vertical"
    android:padding="8dp"
    tools:discard="@layout/unused2"
    tools:keep="@layout/l_used*_c,@layout/l_used_a,@layout/l_used_b*">
    <include layout="@layout/widget_timetable_title_region" />
    <include layout="@layout/widget_timetable_list_meetings" />
    <ListView
        android:id="@+id/widgets_list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:divider="@android:color/transparent"
        android:dividerHeight="2.0sp"
        tools:discard="@layout/unused2"
        tools:keep="@layout/l_used*_c,@layout/l_used_a,@layout/l_used_b*"
        tools:listitem="@layout/widget_item" />
    <TextView
        android:id="@+id/empty_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:text="Loading..."
        android:textColor="@color/white"
        android:textSize="20sp"
        android:textStyle="bold" />
</LinearLayout>

here is the video:

https://jumpshare.com/s/kWcJau9HW5rcsjGq96xw

enter image description here


Solution

  • Try setting a fixed bottom margin for the ListView, it will solve the Problem!

    <ListView
        android:id="@+id/widgets_list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginBottom="15dp" 
        android:divider="@android:color/transparent"
        android:dividerHeight="2.0sp"
        tools:discard="@layout/unused2"
        tools:keep="@layout/l_used*_c,@layout/l_used_a,@layout/l_used_b*"
        tools:listitem="@layout/widget_item" />