45

I have created a custom listView with the row as follows:

 <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 listview code used in my main xml is:

<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 adapter used is as follows:

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 adapter called in main activity through code as follows:

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

My coding is working fine. My problem is that while showing listview which is scrollable is droping shadow at top and bottom of listview and I don't want to show it. How can I remove that shadow?

Thanks in advance

KARASZI István
  • 30,900
  • 8
  • 101
  • 128
Nikki
  • 3,314
  • 13
  • 36
  • 59
  • 1
    Read accepted answer : http://stackoverflow.com/questions/2931953/getting-rid-of-the-gradient-at-the-top-of-an-activity-android. This will work. – Pankaj Kumar Aug 18 '11 at 11:59

6 Answers6

113

I'm assuming you're talking about the fading edges. To disable them:

android:fadingEdge="none"

or

listView.setVerticalFadingEdgeEnabled(false);

UPDATE

As Pim Reijersen pointed out in the comments, android:fadingEdge is deprecated and will be ignored as of API level 14. Please use:

android:fadingEdgeLength="0dp"
mcont
  • 1,749
  • 1
  • 22
  • 33
Romain Piel
  • 11,017
  • 15
  • 71
  • 106
  • 1
    what do you mean by "not working"? if you apply it to any type of view, yes it's working: http://developer.android.com/reference/android/view/View.html#attr_android:fadingEdge – Romain Piel Aug 18 '11 at 11:43
  • 1
    Wow! second one worked for me i.e, dynamically setting listView.setVerticalFadingEdgeEnabled(false); but why first one doesn't....I don't know can any one explain – Nikki Aug 18 '11 at 12:04
  • 2
    android:fadingEdge is deprecated and will be ignored as of API level 14. Use android:fadingEdgeLength="0dp" instead. – Pim Reijersen May 28 '13 at 13:43
  • android:fadingEdgeLength="0dp" was not worked for me, i use the solution from @Chathura Wijesinghe – Joao Ferreira Apr 05 '18 at 10:32
50

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

Add android:overScrollMode="never" to your ScrollView

Chathura Wijesinghe
  • 3,310
  • 3
  • 25
  • 41
  • 1
    I had tried various combinations of `fadingEdge`, `requiresFadingEdge` and `fadingEdgeLength`. Only this one did the trick! – pimguilherme Nov 25 '14 at 05:50
6

Use this in your XML ScrollView:

android:overScrollMode="never"

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

nlmm01
  • 871
  • 9
  • 12
5

It's work for me

android:fadeScrollbars="false"
android:fadingEdge="none"
android:fadingEdgeLength="0dp"
android:cacheColorHint="#00000000"
android:overScrollMode="never"
Woz
  • 350
  • 7
  • 13
1

try below code snippet

listView.setVerticalFadingEdgeEnabled(false);
Yash
  • 1,751
  • 13
  • 14
  • @Yash Let me down-vote it, please check http://stackoverflow.com/a/7106752/792677 for details – A-Live Dec 12 '12 at 20:50
0

add this into XML:

android:fadingEdge="none" or android:fadingEdgeLength="0dp"
JRulle
  • 7,448
  • 6
  • 39
  • 61
Dayanand Waghmare
  • 2,979
  • 1
  • 22
  • 27