簡體   English   中英

Android操作欄自定義布局不適合屏幕

[英]Android action bar custom layout not fit with screen

嗨,我在項目中使用自定義操作欄布局。現在,我遇到了一個問題,即我的自定義布局不適合全屏顯示,並且在searchview點擊時操作欄布局的對齊方式發生了變化。 這是我的自定義布局

<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>

在此處輸入圖片說明 我怎么解決這個問題?? 請幫我 :)

嘗試這個

 <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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM