java - Applying a custom shape to android listview -


hello trying apply custom shape , view android listview. works fine when there enough elements added listview have scroll see of them. if there less looks enter image description here

    <listview     android:id="@+id/recipe_list_view"     android:layout_width="333dp"     android:layout_height="163dp"     android:layout_margintop="46dp"     android:background="@drawable/shape"     android:divider="@color/darkblue"     android:dividerheight="10.0sp"     android:gravity="center"     android:textalignment="center"     app:layout_constraintleft_toleftof="@+id/constraintlayout2"     app:layout_constraintright_torightof="@+id/constraintlayout2"     app:layout_constrainttop_tobottomof="@+id/imageview3"></listview> 

here shape in drawable

    <shape xmlns:android="http://schemas.android.com/apk/res/android"     android:shape="rectangle">     <gradient         android:startcolor="#2ecc71"         android:endcolor="#2ecc71"         android:angle="270"/>      <corners         android:bottomrightradius="7dp"         android:bottomleftradius="7dp"         android:topleftradius="7dp"         android:toprightradius="7dp"/> </shape> 

here code implementing list view

mlistview = (listview) findviewbyid(r.id.listview);             string[] listitems = new string[listofuserids.size()];              for(int = 0; < users.size(); i++){                 listitems[i] = users.get(i);             }              arrayadapter adapter = new arrayadapter(eventdetailsactivity.this, android.r.layout.simple_list_item_1, listitems);             mlistview.setadapter(adapter); 

here looks when there enough elements scroll

enter image description here

you gave background listview, , list view height 163dp, if there few items not fill complete layout. able see backgroud. solution instead of giving fixed height can give wrap_content or instead of giving background list, should give list item.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -