My listview doesn't show last item - android

<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.

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" />

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

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">

Add this MainActivity:
#Override
protected void onResume() {
super.onResume();
View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
);
}

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">

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"

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>

Adding android:layout_height="0dp" to my ListView and android:layout_height="wrap_content" to the parent ViewGroup of my ListView solved the problem

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>

Related

Cannot See BottomBar with ListView

I have this code:
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/swipeContainer"
xmlns:design="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:weightSum="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:theme="#style/Theme.AppCompat"
tools:context="com.tag.instagramdemo.example.MainActivity"
android:background="#drawable/background1">
<ListView
android:id="#+id/lvRelationShip"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</ListView>
<android.support.design.widget.BottomNavigationView
android:id="#+id/bottomBar"
android:layout_width="match_parent"
android:layout_height="64dp"
android:layout_gravity="bottom"
android:background="#ffffff"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:itemIconTint="#color/text"
android:enabled="false"
app:itemTextColor="#color/text"
android:animateLayoutChanges="true"
android:clickable="false"
design:menu = "#menu/menu_main"
android:contextClickable="false"/>
When I use this layout. I can't see the bottom bar and I can only see the listview. At the top there is the list and nothing else.
I tried to resolve your issue.
I hope it will work for you :)
Please have a look and tried
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:design="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/swipeContainer"
android:layout_above="#+id/bottomBar"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:theme="#style/Theme.AppCompat"
android:weightSum="1">
<ListView
android:id="#+id/lvRelationShip"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</ListView>
</android.support.v4.widget.SwipeRefreshLayout>
<android.support.design.widget.BottomNavigationView
android:id="#+id/bottomBar"
android:layout_width="match_parent"
android:layout_height="64dp"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:animateLayoutChanges="true"
android:background="#ffffff"
android:clickable="false"
android:contextClickable="false"
android:enabled="false"
design:menu="#menu/navigation" />
</RelativeLayout>
If you have not added a parent layout, do add a parent layout. Enclose the listview inside swiperefreshlayout and enclose the bottombar & swiperefreshlayout inside a parent layout (for eg., relative layout)
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:design="http://schemas.android.com/apk/res-auto"
....>
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/swipeContainer"
...>
<ListView
android:id=... >
</ListView>
</android.support.v4.widget.SwipeRefreshLayout>
<android.support.design.widget.BottomNavigationView
android:id="#+id/bottomBar"
android:layout_width="match_parent"
android:layout_height="64dp"
android:layout_gravity="bottom"
android:background="#ffffff"
android:enabled="false"
app:itemIconTint="#color/colorAccent"
app:itemTextColor="#color/colorPrimary"
android:animateLayoutChanges="true"
android:clickable="false"
android:contextClickable="false"
android:layout_below="#id/swipeContainer"
app:menu = "#menu/menu_main"/>
Also use
app:menu
instead of design:menu as suggested in
https://medium.com/#chornenkyy.v/first-look-at-bottomnavigationview-from-android-design-library-8244de85b953
BottomNavigationView has a method inflateMenu(menu) and if you pass
your menu resource file inside it will work. Right after idea with the
wrong namespace appear in my mind so I tried to replace ‘design’ with
‘app’ namespace which automatically resolves the attributes. And it
actually works. The same story for other three attributes which exist
specifically for this view: itemBackground, itemIconTint,
itemTextColor.

ListView not utilizing full space in FrameLayout

I have an activity layout with 2 FrameLayout:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
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="de.sioned.multivoc.AddWordActivity"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<include layout="#layout/toolbar_layout"/>
<ScrollView
android:id="#+id/scLeft"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/paneLeft"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/paneLeftTop"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/paneLeftBottom"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/paneLeftTop"/>
</RelativeLayout>
</ScrollView>
</android.support.design.widget.CoordinatorLayout>
The 2nd FrameLayout paneLeftBottom will at some point contain the following fragment:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/lyTop"
android:layout_width="match_parent"
android:layout_height="wrap_content">
...some static fields...
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/lyTop">
<ListView
android:id="#+id/lvResult"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="8dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_marginLeft="16dp"/>
</RelativeLayout>
In this configuration the ListView is only shown with a height of one of it's rows instead several rows utilizing the available space. The ListView works fine but only one row at a time is displayed.
The same ListView fragment works fine when I put it into a 2-pane landscape layout. How can I make the ListView use the available space ?
Edit:
Found a partial solution by switching to a LinearLayout within the ScrollView. Only problem left is, that the bottom Framelayout overlays a bit of the top FrameLayout when I load the said fragment into it. But that is acceptable in this case as it is only temporary to select some data.
<ScrollView
android:id="#+id/scLeft"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
>
<LinearLayout
android:id="#+id/paneLeft"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/paneLeftTop"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/paneLeftBottom"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
</LinearLayout>
</ScrollView>
This right here
android:layout_width="match_parent"
android:layout_height="match_parent"
Should be
android:layout_width="match_parent"
android:layout_height="wrap_content"

set LinearLayout on center android

I have one LinearLayout in which there are two components one is SquareLayout and second one is RecyclerView, i want SquareLayout in center of the screen and RecyclerView in bottom of the screen , don't know why but gravity not work for set it. i am new in android i hope my question is clear. Here is my .xml file..
<LinearLayout 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:orientation="vertical" >
<com.example.layouts.SquareLayout
android:id="#+id/llSelectedLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
></com.example.layouts.SquareLayout>
<android.support.v7.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/rvImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
Use RelativeLayout instead of LinearLayout for do that.
<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:orientation="vertical">
<com.example.gridcollagelayouts.SquareLayout
android:id="#+id/llSelectedLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:centerInParent="true" />
<android.support.v7.widget.RecyclerView
android:id="#+id/rvImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:below="#+id/llSelectedLayout" />
</RelativeLayout>

the RecyclerView I am injecting does not appear?

Here is my xml file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:baselineAligned="false"
android:orientation="horizontal">
<RelativeLayout 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"
android:dividerHeight="10dp"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:showIn="#layout/content_main">
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/DrawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:elevation="7dp">
<!-- Framelayout to display Fragments -->
<FrameLayout
android:id="#+id/frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="#+id/tool_bar"
layout="#layout/tool_bar"></include>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/RecyclerView"
android:layout_width="320dp"
android:layout_height="match_parent"
android:layout_gravity="left"
android:background="#ffffff"
android:scrollbars="vertical">
</android.support.v7.widget.RecyclerView>
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<android.support.v7.widget.RecyclerView
android:id="#+id/threadRecyclerView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scrollbars="vertical" />
</RelativeLayout>
</LinearLayout>
The main reason I did this design was to try to display the
<android.support.v7.widget.RecyclerView
android:id="#+id/threadRecyclerView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scrollbars="vertical" />
properly. However, when it is not being displayed at all. Before adding the two relativelayouts, I have one relative layout and the recyclerview did display, but it match_parent for every item of the list and was not able to fix it. How can I display my view properly?
The problem probably has to do with the layout_height="wrap_content" on your RecyclerView. You need to use setAutoMeasureEnabled(true) for wrap_content to work properly with a RecyclerView.
Here's an example:
RecyclerView threadRecyclerView = (RecyclerView)findViewById(R.id.threadRecyclerView);
threadRecyclerView.getLayoutManager().setAutoMeasureEnabled(true);
And your your XML should look something like this:
<android.support.v7.widget.RecyclerView
android:id="#+id/threadRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
app:layoutManager="LinearLayoutManager"/>
Hope that helps. :)
Note that setAutoMeasureEnabled only works properly for Android Support Library +23.2

Fragment above a recyclerview is not showing

I have searched for solution regarding this issue but couldn't find any solution. I have a fragment which is above a recyclerView. The fragment I am using here is a fragment which came from a library. I have to show that View with a recyclerview. I have done this its working fine. But new requirement is it has to scroll with recyclerview. So for this reason I followed this solution. It seems to be fine but its not showing the entire fragment If I use the layout height to match parent or wrap content. But If I use a value like height = 300dp for that fragment then its showing. But I don't want like that it has to expand and show Can anybody help me to solve this?
this is my fragment.xml
<fragment android:id="#+id/chart"
class="com.shinobicontrols.charts.ChartFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center" />
and recyclerviewLayout.xml
<LinearLayout
android:id="#+id/listViewLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:animateLayoutChanges="true">
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerView1"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
Thanks
If you want that both are on the same screen you should do something like:
<RelativeLayout
android:id="#+id/relativeViewLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true">
<fragment android:id="#+id/chart"
class="com.shinobicontrols.charts.ChartFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center" />
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:below="#+id/chart"/>
</RelativeLayout>
If this isn't that you want, I didn't understand the question.
Please try using like this.. It worked for me
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
tools:context=".MainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment android:id="#+id/chart"
class="com.shinobicontrols.charts.ChartFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center" />
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:below="#+id/chart"/>
</RelativeLayout> </ScrollView>
Simpler solution, i know its too late but maybe someone can use my answer :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment android:id="#+id/chart"
android:layout_alignParentTop="true"
class="com.shinobicontrols.charts.ChartFragment"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_gravity="center" />
<android.support.v7.widget.RecyclerView
android:layout_below="#+id/chart"
android:id="#+id/recyclerView1"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
Right now i've set the height to 100dp just to show you that it renders correctly but you must set it to wrap content (as long as your fragment has an actual height it will render correctly)
Hope this helps :)

Categories

Resources