改xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
android:fitsSystemWindows="true">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary">

<TextView
android:id="@+id/cur_city"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:textColor="#fff"
android:textSize="20sp"/>

<Button
android:id="@+id/back_button1"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_margin="10dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="@drawable/title_back"/>


<ImageButton
android:id="@+id/ib_clear_text"
android:layout_width="20.0dip"
android:layout_height="20.0dip"
android:layout_alignRight="@id/search_edit"
android:layout_centerVertical="true"
android:layout_marginRight="10.0dip"
android:padding="0.0dip"
android:scaleType="centerCrop"
android:src="@drawable/cross"
android:visibility="invisible" />

<Button
android:id="@+id/back_button"
android:layout_width="49.0dip"
android:layout_height="35.0dip"
android:layout_alignParentRight="true"
<!--android:layout_centerVertical="true"-->
android:layout_marginLeft="0.0dip"
android:layout_marginRight="10.0dip"
android:background="@drawable/search_box_cancel_btn_bg"
android:shadowColor="#8fffffff"
android:shadowDy="2.0"
android:shadowRadius="2.0"
android:text="@android:string/cancel"
android:textColor="#ff777777"
android:textSize="15.0sp" />
<EditText
android:id="@+id/search_edit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginBottom="10.0dip"
android:layout_marginLeft="10.0dip"
android:layout_marginRight="10.0dip"
android:layout_marginTop="10.0dip"
android:layout_toLeftOf="@id/back_button"
android:background="@drawable/contact_search_box_edittext_keyword_background"
android:drawableLeft="@drawable/magnifying_glass"
android:drawablePadding="8.0dip"
android:ellipsize="none"
android:hint="@string/biz_plugin_weather_search_city_hint"
android:paddingBottom="8.0dip"
android:paddingLeft="10.0dip"
android:paddingRight="30.0dip"
android:paddingTop="8.0dip"
android:singleLine="true"
android:textColor="#ff000000"
android:textColorHint="#ffcccccc"
android:textSize="15.0sp" />
</RelativeLayout>

<ListView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>

</LinearLayout>

<!--<?xml version="1.0" encoding="utf-8"?>-->
<!--<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"-->
<!--android:layout_width="fill_parent"-->
<!--android:layout_height="wrap_content"-->
<!--android:background="@drawable/contact_search_box_background"-->
<!--android:focusable="true"-->
<!--android:focusableInTouchMode="true" >-->




<!--<?xml version="1.0" encoding="utf-8"?>-->
<!--<LinearLayout-->
<!--xmlns:android="http://schemas.android.com/apk/res/android"-->
<!--android:orientation="vertical"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="match_parent"-->
<!--android:background="#fff"-->
<!--android:fitsSystemWindows="true">-->

<!--<RelativeLayout-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="?attr/actionBarSize"-->
<!--android:background="?attr/colorPrimary">-->

<!--<TextView-->
<!--android:id="@+id/cur_city"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_centerInParent="true"-->
<!--android:textColor="#fff"-->
<!--android:textSize="20sp"/>-->

<!--<Button-->
<!--android:id="@+id/back_button"-->
<!--android:layout_width="40dp"-->
<!--android:layout_height="40dp"-->
<!--android:layout_margin="10dp"-->
<!--android:layout_alignParentRight="true"-->
<!--android:layout_centerVertical="true"-->
<!--android:background="@drawable/title_back"/>-->
<!--</RelativeLayout>-->

<!--<ListView-->
<!--android:id="@+id/list_view"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="match_parent"/>-->

<!--</LinearLayout>-->
原文地址:https://www.cnblogs.com/tianzijiaozi/p/7577412.html