android - AutoComplete EditText 选择器,会怎么样?

标签 android autocomplete android-widget css-selectors

我正在使用 AutoCompleteEditText,我想让它看起来像 enter image description here

但我不知道会怎样。

最佳答案

执行此操作的一般方法是使用 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/

相关文章:

javascript - 预定义单词的 CodeMirror 编辑器自动完成

android - 是否可以仅针对某个 android 版本显示小部件?

android - 将动画添加到 android-wheel

android - 在工具栏上 app :popupTheme ="@style/AppTheme.PopupOverlay" do? 是什么

AndroidAnnotations + Instant App - 找不到生成的 <applicationId>.R 类

autocomplete - pycharm python 控制台自动完成

c# - 如何在 Visual Studio 中获取参数提示/完成?

android - 为空间小部件着色

android - Jacoco gradle 'exclude'无法在Kotlin的Android项目中使用

Android map ,在 Overlay 构造函数中绘制