Remove shadow above and below ListView in Android?

I created my own listView with the following line:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:id="@+id/lay1" android:layout_height="wrap_content" android:background="#ffffff"> <TextView android:layout_width="fill_parent" android:textColor="#000000" android:id="@+id/text" android:layout_height="wrap_content" android:layout_toRightOf="@+id/check" android:textSize="15dip" android:paddingBottom="5dip" android:paddingRight="10dip" android:paddingLeft="10dip"></TextView> <Button android:id="@+id/check" android:layout_centerVertical="true" android:background="@drawable/uncheck" android:layout_width="wrap_content" android:layout_height="wrap_content" android:visibility="gone"></Button> <EditText android:layout_width="fill_parent" android:textColor="#000000" android:id="@+id/edit" android:layout_height="wrap_content" android:background="@null" android:layout_below="@+id/text" android:textSize="15dip" android:paddingTop="5dip" android:paddingRight="10dip" android:paddingLeft="10dip" android:layout_toRightOf="@+id/check" android:paddingBottom="5dip" ></EditText> </RelativeLayout> 

And the list code used in my main xml:

 <ListView android:layout_width="450dip" android:background="#FFFFFF" android:layout_height="340dip" android:layout_marginLeft="9dip" android:layout_marginTop="10dip" android:id="@+id/mainlist1" android:divider="@drawable/grayline" android:cacheColorHint="#00000000" ></ListView> 

And the adapter used:

 public class Adapter extends BaseAdapter { ArrayList<Row> row; private Context context; public Adapter(Context context, ArrayList<SongRow> songrow) { this.context = context; this.row = row; } public int getCount() { return row.size(); } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View convertView, ViewGroup parent) { long sub_id = row.get(position).getSub_id(); String sub_title = row.get(position).getSub_title(); String sub_text = row.get(position).getSub_text(); if (convertView == null) { LayoutInflater inflat = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = inflat.inflate(R.layout.mainrow, null); } else { LayoutInflater inflat1 = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = inflat1.inflate(R.layout.mainrow, null); } final TextView name = (TextView) convertView.findViewById(R.id.text); final EditText et = (EditText) convertView.findViewById(R.id.edit); name.setText(sub_title); et.setText(sub_text); et.setFilters(new InputFilter[] { new InputFilter() { public CharSequence filter(CharSequence src, int start, int end, Spanned dst, int dstart, int dend) { InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); mgr.hideSoftInputFromWindow(et.getWindowToken(),0); et.setCursorVisible(false); return dst.subSequence(dstart, dend); } } }); et.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { // TODO Auto-generated method stub if (hasFocus) { InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); mgr.hideSoftInputFromWindow(et.getWindowToken(),0); et.setCursorVisible(false); } } }); et.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); mgr.hideSoftInputFromWindow(et.getWindowToken(),0); et.setCursorVisible(false); } }); return convertView; } } 

And the adapter, called in the main action using code as follows:

 Adapter s = new Adapter(MainActivity.this, row); mainlist.setAdapter(s); mainlist.setSelection(length-1); 

My encoding is working fine. My problem is that when I show a listview that is scrollable, it casts a shadow above and below the list, and I don’t want to show it. How to remove this shadow?

Thank you in advance

+42
android listview
Aug 18 '11 at 11:30
source share
6 answers

I assume that you are talking about disappearing edges. To disable them:

 android:fadingEdge="none" 

or

 listView.setVerticalFadingEdgeEnabled(false); 

UPDATE

As Pim Reyersen noted in the comments, android:fadingEdge deprecated and will be ignored from API level 14. Please use:

 android:fadingEdgeLength="0dp" 
+111
Aug 18 '11 at 11:35
source share

android:fadingEdgeLength did not work for me, I used and worked well with android:overScrollMode="never"

Add android:overScrollMode="never" to your ScrollView

+40
Aug 28 '13 at 17:35
source share

Use this in your XML ScrollView:

 android:overScrollMode="never" 

You can set it to always, never, or ifContentScrolls.

+6
Feb 25 '15 at 5:40
source share

It works for me

 android:fadeScrollbars="false" android:fadingEdge="none" android:fadingEdgeLength="0dp" android:cacheColorHint="#00000000" android:overScrollMode="never" 
+5
Dec 15 '14 at 23:35
source share

try to find the code snippet

 listView.setVerticalFadingEdgeEnabled(false); 
+1
Jul 24 2018-12-12T00:
source share

add this to the XML:

 android:fadingEdge="none" or android:fadingEdgeLength="0dp" 
0
Dec 31 '15 at 12:02
source share



All Articles