I want to create a searchview if possible or an edittext similar to that, i beleive It's in holo theme but my project theme is Appcompact, thnx.
Asked
Active
Viewed 598 times
1

Maksim Ostrovidov
- 10,720
- 8
- 42
- 57

rawa300
- 27
- 1
- 8
-
try using custom background using xml drawable for edittext – Sodiq Nov 04 '16 at 07:22
-
thanks, but that is my problem I don't know how to exactly make that. – rawa300 Nov 04 '16 at 07:28
-
Refer [here](http://stackoverflow.com/questions/3646415/how-to-create-edittext-with-rounded-corners) on how to make a editText with rounded corners – John Joe Nov 04 '16 at 07:33
-
@rawa300 after using xml drawable then using clip drawable – Sodiq Nov 04 '16 at 07:47
-
thanks guys I believe this will do the trick :) – rawa300 Nov 04 '16 at 07:53
1 Answers
1
in your layout file
<EditText
android:id="@+id/editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="EditText"
android:padding="8dp"
/>
edit_text_drawable.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="16dp"/>
<solid android:color="@android:color/transparent"/>
<stroke
android:color="@color/colorBlue"
android:width="2dp" />
</shape>
This drawable will be used as EditText's background. Tag stroke makes outline for this shape - set outline width & color here.
in your code
EditText editText = (EditText) findViewById(R.id.editText);
ClipDrawable clipDrawable = new ClipDrawable
(getResources().getDrawable(R.drawable.edit_text_drawable),
Gravity.BOTTOM, ClipDrawable.VERTICAL);
clipDrawable.setLevel(2000);
editText.setBackground(clipDrawable);
Here ClipDrawable "crops" backround drawable. ClipDrawable documentation

Maksim Ostrovidov
- 10,720
- 8
- 42
- 57