How to remove default divider from recylerview - android

I have added android-recyclerview in my app which is running fine. According to my layout i have to remove divider between cells. In list view this can easily be achieved by setting divider property to null like below in code but i am not able to find any such property in android-recyclerview. How can i achieve this in android-recyclerview.
getListView().setDivider(null);
getListView().setDividerHeight(0);
OR
android:divider="#null"
android:dividerHeight="0dp"
Recylerview xml below :
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view_contact_list_frag"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.8"
android:clickable="true"
android:focusable="true"
android:scrollbars="vertical" />
Adapter xml :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#drawable/recyclerview_item_borders"
android:padding="10dp">
<LinearLayout
android:id="#+id/section_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:paddingBottom="30dp"
>
<TextView
android:id="#+id/textview_section_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<de.hdodenhof.circleimageview.CircleImageView xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/circular_image_contact"
android:layout_width="#dimen/auto_complete_circular_image_dimen"
android:layout_height="#dimen/auto_complete_circular_image_dimen"
app:civ_border_color="#FF000000"
android:layout_weight="0.2"
android:src="#mipmap/ic_default_contact"
app:civ_border_width="0dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.8"
android:orientation="vertical">
<TextView
android:id="#+id/textView_contact_name"
android:layout_width="match_parent"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:layout_marginLeft="#dimen/activity_horizontal_margin"
android:textColor="#color/textDarkColor"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" />
<TextView
android:id="#+id/textView_contact_number"
android:layout_width="match_parent"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:layout_marginLeft="#dimen/activity_horizontal_margin"
android:textColor="#color/textDarkColor"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" />
</LinearLayout>
</LinearLayout>

Remove background from adapter
android:background="#drawable/recyclerview_item_borders"

Recyclerview don't have the divider by default. If you need to add the divider, you have to add the decoration to the recyclerview.

It is from the custom view you are using by default there is no divider. share your code thn any one can help you.

You need to change it in the List item view. Add following parameters to list item view.
card_view:cardCornerRadius="0dp"
card_view:cardElevation="0dp"
card_view:cardUseCompatPadding="true"
In list_item_view.xml
<android.support.v7.widget.CardView
android:id="#+id/card_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
card_view:cardCornerRadius="0dp"
card_view:cardElevation="0dp"
card_view:cardUseCompatPadding="true">
Then set background color of your Recycle view to its foreground color. If it is white,
In recycle_view.xml
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="match_parent"
android:background="#ffffff"
android:scrollbars="vertical"
android:layout_height="wrap_content"/>

Related

ListView not scrolling for Xamarin.Android app

I've placed a fragment tag on my page for a google map and a listview surrounded by a linear layout tag underneath the map. Does anyone know why my list view isn't scrolling. I set my listview fastscrollenabled setting to true and it still doen't scroll.
var locationService = new LocationService(_geoCoder);
listView.Adapter = new ListOfLocationAdapter(this, locationService.GetLatLongOfAddresses());
this.listView.FastScrollEnabled = true;
Here is the XAML I use for the layout.
<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:rowCount="2"
android:columnCount="1">
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="300dp"
class="com.google.android.gms.maps.MapFragment" />
<LinearLayout
android:id="#+id/linearLayout1"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="#+id/List"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:cacheColorHint="#FFDAFF7F"/>
</LinearLayout>
</GridLayout>
Here is the listadapter code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:minHeight="50dp"
android:orientation="vertical"
android:background="#ffffff">
<LinearLayout
android:id="#+id/Text"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:orientation="vertical">
<TextView
android:id="#+id/CustomerName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textSize="20dip"
android:textStyle="italic"
android:paddingLeft="10dip" />
<TextView
android:id="#+id/Address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14dip"
android:textColor="#000000"
android:paddingLeft="10dip" />
</LinearLayout>
</RelativeLayout>
I tried removing the relativelayout tag, but that didn't do anything for me.
Set weight to your listview & set height to 0dp. This will make it auto-fill any remaining space, causing the internal items of the listview to scroll.
<ListView
android:id="#+id/List"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:cacheColorHint="#FFDAFF7F" />
When I move the linearlayout around both the fragment and listview the scrolling starts working. For some reason the linear layout was showing off of the bottom of the android layout making it look like it wasn't scrolling until I added more records.
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:rowCount="2"
android:columnCount="1">
<LinearLayout
android:id="#+id/linearLayout1"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="300dp"
class="com.google.android.gms.maps.MapFragment" />
<ListView
android:id="#+id/List"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:cacheColorHint="#FFDAFF7F" />
</LinearLayout>
</GridLayout>
I had the same problem. I just set layout_height of my ListView to match_parent value. This solved my problem.

android recyclerview gridview item not showing properly

I am using recyclerview gridview to show product. But its showing like this
this is the view
my xml view code is
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/tools"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:id="#+id/card_view"
android:layout_width="#dimen/cover_height"
android:layout_height="wrap_content"
android:layout_gravity="center"
card_view:cardUseCompatPadding="true"
android:elevation="7dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.makeramen.roundedimageview.RoundedImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/thumbnail"
android:src="#drawable/placeholder_image"
android:scaleType="fitXY"
app:riv_oval="false"
app:riv_corner_radius_top_left="6dp"
app:riv_corner_radius_top_right="6dp"
android:layout_height="#dimen/cover_height"
android:layout_width="match_parent" />
<pseudozero.smalam.com.finwallet.utils.TextViewPlus
android:id="#+id/tvProductTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/thumbnail"
android:textColor="#color/colorBlack"
android:textSize="15dp"
android:text="Wrist Watch"
android:padding="5dp"
app:customFont="fonts/Proxima_Nova_Bold.otf"/>
<pseudozero.smalam.com.finwallet.utils.TextViewPlus
android:id="#+id/tvProductVendor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/tvProductTitle"
android:textSize="13dp"
android:paddingLeft="5dp"
android:paddingBottom="5dp"
android:text="Rolex"
app:customFont="fonts/Proxima_Nova_Reguler.otf"/>
<pseudozero.smalam.com.finwallet.utils.TextViewPlus
android:id="#+id/tvPriceTag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="500 BDT"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:textColor="#color/colorWhite"
android:textSize="13dp"
android:padding="10dp"
android:background="#drawable/price_tag_back_n"
app:customFont="fonts/Proxima_Nova_Bold.otf"/>
</RelativeLayout>
</android.support.v7.widget.CardView>
I am using a card view inside linearlayout. But I am getting this
I am loading all data from server. Only the second item is going up. I want that all items will be decorated.
Use fixed height of CardView and RoundedImageView
Use attribute android:scaleType="centerCrop" instead of android:scaleType="fitXY" to RoundedImageView.
Hope this will help~
RelativeLayout Height should be wrap_content
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
to
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
And in your code you do not close parent LinearLayout.

Two ListView in ScrollView

I have put two listview in scrollview but i have a problem, when i put item in the first listview the second listview will be scrollable. I want that the whole area will be scrollable and not scrollview, How i do? the first scrollview is listViewEventiAggiunti the second listViewEventi.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
android:layout_height="match_parent"
android:layout_width="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:fillViewport="true">
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:id="#+id/activity_lista__eventi"
android:paddingBottom="#dimen/padBottom"
android:paddingLeft="#dimen/padLeft"
android:paddingRight="#dimen/padRight"
android:paddingTop="#dimen/padTop"
xmlns:android="http://schemas.android.com/apk/res/android"
tools:context="com.example.fra87.eudroid.activity_class.Lista_Eventi">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="vertical">
<SearchView
android:layout_width="match_parent"
android:layout_height="50dp"
android:queryHint="Evento"
android:id="#+id/cercaEvento"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:id="#+id/linearLayoutEventi">
<EditText
android:layout_width="match_parent"
android:layout_height="50dp"
android:hint="Nome Evento"
android:textSize="22dip"
android:id="#+id/editText_nome_evento_composto"/>
<ListView
android:id="#+id/listViewEventiAggiunti"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp" />
<View
android:layout_width="match_parent"
android:layout_height="5dp"
android:id="#+id/separatore_liste"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:background="#android:color/darker_gray"/>
<ListView
android:id="#+id/listViewEventi"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/cercaEvento"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp" />
</LinearLayout>
</LinearLayout>
</ScrollView>
I want scroll entire area, i don't want scroll on listview, when i put item in listview the area increases and i scroll entire area is possible?
Ok. Since your minimum SDK version is 16, you have 2 solution for your problem.
First is use this library:
https://github.com/PaoloRotolo/ExpandableHeightListView
This library makes you able to expand your ListViews to full height and then only your ScrollView will be scrollable.
Second solution is to use NestedScrollView instead of ScrollView and then use RecyclerView instead of ListView. Then you should only disable nestedScrolling for your RecyclerView.
Both solutions will give you your desire behavior.
You can use multiple type item for listview and simplified your layout to become like this
<?xml version="1.0" encoding="utf-8"?><?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:id="#+id/activity_lista__eventi"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="#dimen/padBottom"
android:paddingLeft="#dimen/padLeft"
android:paddingRight="#dimen/padRight"
android:paddingTop="#dimen/padTop"
tools:context="com.example.fra87.eudroid.activity_class.Lista_Eventi"
>
<SearchView
android:id="#+id/cercaEvento"
android:layout_width="match_parent"
android:layout_height="50dp"
android:queryHint="Evento"
/>
<EditText
android:id="#+id/editText_nome_evento_composto"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_below="#+id/cercaEvento"
android:hint="Nome Evento"
android:textSize="22dip"
/>
<View
android:id="#+id/separatore_liste"
android:layout_width="match_parent"
android:layout_height="5dp"
android:layout_below="#+id/editText_nome_evento_composto"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:background="#android:color/darker_gray"
/>
<ListView
android:id="#+id/listViewEventi"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/separatore_liste"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
/>
</RelativeLayout>

RecycleView Not Scrolling by adding RelatvieLayout below It

I have viewpager at the top to slide and view images . and after a list to see remaining images or whatever i want to display in list and after that i have a RelativeLayout below this list which i will populate with the Code
Now Issue is :-
I am facing a problem with RecycleView . It was working fine until i add a RelativeLayout to parentofbottom and setting RecycleView property to above this RelativeLayout . Now Issue is RecycleView is not scrolling at all . whats wrong with the code. What needs to be change .Or Suggest me anyother way to achieve this design
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawer_layout"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<RelativeLayout
android:id="#+id/container"
android:layout_width="match_parent"
android:focusableInTouchMode="true"
android:layout_height="match_parent" >
<RelativeLayout
android:id="#+id/relativeHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="#color/headecolor" >
<Button
android:id="#+id/btnOpenDrawer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:background="#drawable/menu_icon" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="#drawable/alert_icon" />
<TextView
android:id="#+id/txtTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textStyle="bold"
android:text="A La Une"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/blackColor" />
</RelativeLayout>
<android.support.v4.widget.NestedScrollView
android:id="#+id/scroler"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/relativeHeader"
android:fillViewport="true"
android:background="#android:color/white" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusableInTouchMode="true"
android:background="#android:color/white" >
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="wrap_content"
android:descendantFocusability="blocksDescendants"
android:layout_height="wrap_content" >
<RelativeLayout
android:id="#+id/rlPager"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<egdigital.alpes1.view.WrapContentViewPager
android:id="#+id/view_pager"
android:layout_width="match_parent"
android:layout_height="220dp"
android:adjustViewBounds="true"
android:background="#drawable/news_img_transparent"
/>
<ImageView
android:id="#+id/imageView_dot"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/view_pager"
android:layout_alignParentLeft="true"
android:src="#drawable/scroll_dot1" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/rlRecycle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/relativeLayout1"
android:layout_above="#+id/rlMiniPlayer"
>
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingBottom="80dp">
</android.support.v7.widget.RecyclerView>
</RelativeLayout>
<RelativeLayout
android:id="#+id/rlMiniPlayer"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_alignParentBottom="true"
>
</RelativeLayout>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
</RelativeLayout>
<fragment
android:id="#+id/navigation_drawer"
android:name=".NavigationDrawerFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
android:layout_marginLeft="25dp"
tools:layout="#layout/fragment_navigation_drawer" />
</android.support.v4.widget.DrawerLayout>
1) Change
android:layout_below="#+id/relativeLayout1"
to android:layout_below="#id/relativeLayout1" and change anywhere else you have layout_below or layout_above
+ is used when creating a new id. When giving an already created id we use it without +
2) You don't really need RelativeLayout with id rlRecycle. You can directly move layout_below and layout_above attributes to RecyclerView because it's already under top level RelativeLayout
I Found The Solution . i know there are lots of extra RelativeLayouts . Know I removed it . and putted rlMiniPlayer below the nested scrollview
Because I am using nestedscrolling=true . in the code . This is creating the problem
Like This :-
</android.support.v4.widget.NestedScrollView>
<RelativeLayout
android:id="#+id/rlMiniPlayer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
>
</RelativeLayout>

Two buttons showing when only creating one in XML

I am creating my layout entirely in XML. I wish to show a ListView and always have a button at the bottom of the screen like in the default FullScreenActivity. However, the issue is that the button that is at the bottom is also appearing at the top of the screen.
<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:background="#ff000000"
tools:context=".ChannelNameActivity">
<ListView
android:id="#+id/channelListView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:keepScreenOn="true"
android:layout_weight="1"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#color/black_overlay"
android:orientation="horizontal"
tools:ignore="UselessParent">
<Button
android:id="#+id/dummy_button"
style="?metaButtonBarButtonStyle"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="#string/dummy_button" />
</LinearLayout>
</RelativeLayout>
(Code note from OP's previous question: ArrayAdapter unable to update contents)
Because in your onCreate() you are adding Activity Layout as Header View to your ListView which is unnecessary (not required).
So Just remove below code lines from onCreate()
final View contentView = (View)getLayoutInflater().inflate(R.layout.activity_channelname, null);
channelListView.addHeaderView(contentView);
Here you have to use android:layout_above="#+id/lnlLayout" attribute in ListView and android:alignParentBottom="true" on LinearLayout
<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:background="#ff000000"
tools:context=".ChannelNameActivity">
<ListView
android:id="#+id/channelListView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/lnlLayout"
android:keepScreenOn="true"/>
<LinearLayout
android:id="#+id/lnlLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#color/black_overlay"
android:layout_alignParentBottom="true"
android:orientation="horizontal"
tools:ignore="UselessParent">
<Button
android:id="#+id/dummy_button"
style="?metaButtonBarButtonStyle"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="#string/dummy_button" />
</LinearLayout>
</RelativeLayout>

Categories

Resources