我正在使用 AutoCompleteEditText
,我想让它看起来像
但我不知道会怎样。
最佳答案
执行此操作的一般方法是使用 9-patch 更多信息,请点击此处 http://developer.android.com/guide/developing/tools/draw9patch.html .但在这种情况下,您可以使用更简单的解决方案。
在你的主布局中
<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>
透明背景.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>
如果需要,修正你的颜色或尺寸。
关于android - AutoComplete EditText 选择器,会怎么样?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5309406/