My listview doesn't show last item

吃可爱长大的小学妹 提交于 2020-03-13 05:22:08

问题


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="info.androidhive.materialtabs.fragments.OneFragment">

    <ListView
        android:id="@+id/olaylar_liste"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"></ListView>
</LinearLayout>

Last item is not showing. Please help.


回答1:


Add this line to your Viewpager

android:layout_marginBottom="?attr/actionBarSize"

because the size you don't have at bottom is exactly the size taken by your ToolBar,

which is supposed to be hide (using new Android Design) when you reach to bottom.

    <android.support.v4.view.ViewPager
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginBottom="?attr/actionBarSize"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />



回答2:


as you see your device is a bit smaller than content of your ListView.

Solution 1.

Add paddingBottom with at least 20dp value to your olaylar_liste ListView.

Try also if previous doesn't work, adding also marginBottom="20dp".

Solution 2.

Try to implement ScrollView like below:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="info.androidhive.materialtabs.fragments.OneFragment">

  <ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="20dp"> //THIS GUY would be useful

    <ListView
        android:id="@+id/olaylar_liste"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    </ListView>

  </ScrollView> 

</LinearLayout>

Read also: Working with the ScrollView

Hope it help




回答3:


Try this.

<ListView

        android:id="@+id/lv_content"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="@color/bg_listview"
        android:dividerHeight="1dp">



回答4:


Add this MainActivity:

@Override
protected void onResume() {
    super.onResume();
    View decorView = getWindow().getDecorView();
    decorView.setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            );
}



回答5:


Add android:paddingBottom to ViewFlipper it works for me.

<ViewFlipper
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   android:id="@+id/fragment_workorder_list_viewFlipper"
   android:layout_width="match_parent"
   android:layout_height="fill_parent"
   android:paddingBottom="?attr/actionBarSize">



回答6:


Im using tableview from de.codecrafters:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.vlad.zimmer.porProgramar$PlaceholderFragment">
    <de.codecrafters.tableview.TableView
        android:id="@+id/tableView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="?attr/actionBarSize"
        />
</RelativeLayout>

Adding this line, works for me like a charm:

android:layout_marginBottom="?attr/actionBarSize"




回答7:


Use this

 <FrameLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">
                    <ListView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content">

                    </ListView>
    </FrameLayout>



回答8:


you must set android:paddingBottom="" in your list view or recyclerview.

    <android.support.v7.widget.RecyclerView
    android:id="@+id/recycler_prod_category"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_constraintRight_toRightOf="parent"
    android:paddingBottom="?attr/actionBarSize"
    app:layout_constraintTop_toTopOf="parent">
</android.support.v7.widget.RecyclerView>


来源:https://stackoverflow.com/questions/34449336/my-listview-doesnt-show-last-item

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!