Reputation: 4221
How can I make a customized search-box for my android application? Something like this, for example :
Or if it's hard, is it possible to use the Android SearchManager
in local app?
Upvotes: 0
Views: 1608
Reputation: 3681
For the background I think it's easier to use a drawable shape like this:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<corners android:radius="10dp" />
<solid android:color="@android:color/white" />
<padding
android:left="8dp"
android:right="8dp"
android:top="8dp"
android:bottom="8dp" />
</shape>
The radius gives the background the rounded borders and can be easily adjusted, so is the size changing the padding.
Upvotes: 1
Reputation: 13247
As bughi stated, use custom background 9-patch drawables for your widget.
The second image consists of EditText and ImageButton placed next to each other.
Use 9-patch drawable like this for EditText and 9-patch drawable like this for ImageButton .
Sure use selector as android:background
for widget states as normal, pressed and focused.
First image can be achieved also by using attribute android:drawableRight
.
Overriden onTouchEvent()
method of your widget can look like this:
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_UP && event.getX() >= getWidth() - getCompoundPaddingRight()) {
// search drawable was touched
}
...
}
Upvotes: 2