AutoCompleteEditText selector, how it will be?
I am using an AutoCompleteEditText
and I w开发者_运维百科ant to make it appearance as
But I don't know how it will be.
The general way to do this is by using 9-patch more info here http://developer.android.com/guide/developing/tools/draw9patch.html. But in this case you can use simpler solution.
in your main layout
<RelativeLayout android:layout_width="fill_parent"
android:id="@+id/searchfieldlayout" android:layout_height="46dp"
android:background="#0000ff">
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="32dp" android:layout_centerInParent="true"
android:layout_marginLeft="7dp" android:layout_marginRight="7dp"
android:background="@drawable/search_gradient">
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/search_icon"
android:layout_alignParentLeft="true" android:layout_centerVertical="true"
android:layout_marginLeft="10dp" android:background="@drawable/search_icon">
</ImageView>
<EditText android:layout_width="fill_parent" android:id="@+id/searchfield"
android:paddingTop="5dp" android:textSize="13dp" android:textColor="#ffffffff"
android:selectAllOnFocus="true" android:paddingRight="10dp"
android:paddingBottom="5dp" android:paddingLeft="10dp"
android:layout_height="fill_parent" android:layout_toRightOf="@+id/search_icon"
android:background="@drawable/transparent_background"
android:layout_marginLeft="7dp" android:inputType="text" android:imeOptions="actionGo">
</EditText>
</RelativeLayout>
</RelativeLayout>
search_gradien.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:startColor="#2b0139" android:endColor="#3e1550" android:angle="270" />
<corners android:radius="6dp" />
</shape>
transparent_background.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:startColor="#00000000" android:endColor="#00000000"
android:angle="270" />
</shape>
fix your colors or dimensions if needed.
精彩评论