简体   繁体   中英

Android action bar custom layout not fit with screen

Hi I am using custom action bar layout in my project.Now I have a problem that my custom layout is not fit to full screen and action bar layout alignment changes on searchview click. This is my custom layout

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" 
 >

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="40dp" 
    android:background="#585858">

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:layout_weight="0.5"
         android:gravity="center" >
         <ImageView
            android:id="@+id/imageView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_launcher" 
            android:scaleType="centerInside"/>
    </LinearLayout>
    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:orientation="vertical"
         android:layout_weight="1"
          android:gravity="center" >

        <SearchView
            android:id="@+id/searchView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="right" >
        </SearchView>

    </LinearLayout>

</LinearLayout>

 </LinearLayout>

在此处输入图片说明 How can i solve this problem?? please help me :)

Try this

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="40dp"
    android:background="#585858">

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:gravity="center" >
        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_launcher"
            android:scaleType="centerInside"/>
    </LinearLayout>
    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:layout_weight="1"
        android:gravity="center" >

        <SearchView
            android:id="@+id/searchView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="right" >
        </SearchView>

    </LinearLayout>

</LinearLayout>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM