Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 使用EditText和微调器创建向下导航的自定义搜索_Android_Xml_Eclipse - Fatal编程技术网

Android 使用EditText和微调器创建向下导航的自定义搜索

Android 使用EditText和微调器创建向下导航的自定义搜索,android,xml,eclipse,Android,Xml,Eclipse,我正在尝试使用EditText创建自定义搜索,并使用微调器向下导航。我想让它像下图一样 基本设计图像-> 但这就是我现在拥有的 完成设计-> 这是我的xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/main_layout" andr

我正在尝试使用EditText创建自定义搜索,并使用微调器向下导航。我想让它像下图一样

基本设计图像->

但这就是我现在拥有的

完成设计->

这是我的xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/main_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="70dp"
        android:padding="10dp"
        android:background="@drawable/background_with_shadow">

        <EditText
            android:id="@+id/searchFilter"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:ems="10"
            android:maxLines="1"
            android:padding="10dp"
            android:hint="@string/search_hint"
            android:textColor="@color/grey_blue"
            android:singleLine="true"
            android:layout_gravity="center"
            android:textColorHint="#BDBDBD"
            android:ellipsize="start"
            android:background="@drawable/filter_bg"
            />

        <Spinner
            android:layout_width="50dp"
            android:layout_height="match_parent"
            android:id="@+id/spinner"
            android:padding="10dp"
            android:layout_alignBottom="@+id/searchFilter"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:background="@android:drawable/btn_dropdown"
            android:spinnerMode="dropdown"
            />
    </RelativeLayout>


</LinearLayout>
<?xml version="1.0" encoding="utf-8" ?>

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle"
    android:thickness="0dp">
    <stroke
        android:width="1dp"
        android:color="#b71c1c" />
    <corners android:radius="3dp" />
    <gradient
        android:angle="270"
        android:endColor="#FFFFFF"
        android:startColor="#C8C8C8"
        android:type="linear" />
</shape>

My filter_bg.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/main_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="70dp"
        android:padding="10dp"
        android:background="@drawable/background_with_shadow">

        <EditText
            android:id="@+id/searchFilter"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:ems="10"
            android:maxLines="1"
            android:padding="10dp"
            android:hint="@string/search_hint"
            android:textColor="@color/grey_blue"
            android:singleLine="true"
            android:layout_gravity="center"
            android:textColorHint="#BDBDBD"
            android:ellipsize="start"
            android:background="@drawable/filter_bg"
            />

        <Spinner
            android:layout_width="50dp"
            android:layout_height="match_parent"
            android:id="@+id/spinner"
            android:padding="10dp"
            android:layout_alignBottom="@+id/searchFilter"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:background="@android:drawable/btn_dropdown"
            android:spinnerMode="dropdown"
            />
    </RelativeLayout>


</LinearLayout>
<?xml version="1.0" encoding="utf-8" ?>

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle"
    android:thickness="0dp">
    <stroke
        android:width="1dp"
        android:color="#b71c1c" />
    <corners android:radius="3dp" />
    <gradient
        android:angle="270"
        android:endColor="#FFFFFF"
        android:startColor="#C8C8C8"
        android:type="linear" />
</shape>


有人能帮我把它做成第一张图片吗?谢谢

如下更改布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/main_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <LinearLayout 
        android:layout_width="match_parent"
        android:layout_height="70dp"
        android:background="@drawable/background_with_shadow"
        android:orientation="horizontal">

        <Spinner
            android:layout_width="50dp"
            android:layout_height="match_parent"
            android:id="@+id/spinner"
            android:padding="10dp"
            android:background="@android:drawable/btn_dropdown"
            android:spinnerMode="dropdown"
            />

        <EditText
            android:id="@+id/searchFilter"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:ems="10"
            android:maxLines="1"
            android:padding="10dp"
            android:hint="@string/search_hint"
            android:textColor="@color/grey_blue"
            android:singleLine="true"
            android:layout_gravity="center"
            android:textColorHint="#BDBDBD"
            android:ellipsize="start"
            android:background="@drawable/filter_bg"
            />


    </LinearLayout>


</LinearLayout>

使用相对布局和未正确设置组件关系是问题所在。这里很容易使用衬里布局