The fade effects around the edittext edges in android

394 views Asked by At

I need to design the search textbox with the fade effects around the edges.(Please look at the picture by link: The fade effect around the edges).

Anybody can give me an idea?

Thanks.

1

There are 1 answers

1
steven0529 On

You can to it by simply create a Class lets say YourCustomEditText and extending the default EditText class. You can to it like this:

public class YourCustomEditText extends EditText
  • Then override the OnDraw method, only call the super(canvas) at the end so it wont draw as the default look.

    @Override
    protected void onDraw(Canvas canvas) {
       canvas.drawColor(Color.WHITE);
       canvas.save();
       super.onDraw(canvas);
       canvas.restore();
    }
    
  • instantiate it in the activity

    YourCustomEditText yourCustomEditText;

  • then on the onCreate of the activity, you can cast it as an YourCustomEditText even with same EditText tag

    yourCustomEditText = (YourCustomEditText) findViewById(R.id.customEditText);