簡體   English   中英

屏幕底部帶有自定義ActionBar的Android項目在鍵盤上方浮動

[英]Android project with Custom ActionBar on Bottom of screen is floating up above the Keyboard

我正在使用xamarin開發一個android項目,並且在屏幕底部有一個自定義操作欄。 我在大約三個不同的屏幕之間使用它,但是由於某種原因,當鍵盤出現時,在帶有edittext和listview的屏幕上,導航欄出現在鍵盤上方,而不應該出現。 就像下面的圖片

外觀不正確:

在此處輸入圖片說明

當鍵盤出現時,導航欄上會顯示“?” 圖片按鈕不應該在那里。

xml代碼:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:orientation="vertical"
    android:layout_height="match_parent"
    android:layout_centerHorizontal="true"
    android:id="@+id/LocationsRoot"
    android:gravity="center_vertical|center_horizontal">
    <include
        android:id="@+id/toolbar"
        layout="@layout/toolbar" />
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_centerInParent="true"
        android:orientation="vertical"
        android:layout_below="@id/toolbar">
        <TextView
            android:id="@+id/SearchView"
            android:layout_centerHorizontal="true"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center_vertical"
            android:layout_marginTop="15dp"
            android:background="#d3d3d3"
            android:textSize="30dp"
            android:text=" Select Location" />
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="#d3d3d3"
                android:orientation="horizontal">
                <EditText
                    android:layout_width="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:layout_marginRight="20dp"
                    android:layout_marginBottom="5dp"
                    android:id="@+id/SearchText"
                    android:hint="Search"
                    android:layout_centerInParent="true"
                    android:background="#FFFFFF"
                    android:gravity="center"
                    android:layout_weight="10"
                    android:layout_height="match_parent" />
                <ImageButton
                    android:id="@+id/SearchLocationButton"
                    android:layout_width="wrap_content"
                    android:background="@drawable/GreenButton"
                    android:layout_marginBottom="5dp"
                    android:layout_height="wrap_content"
                    android:layout_alignParentRight="true"
                    android:layout_weight="1"
                    android:src="@drawable/search32x32" />
            </LinearLayout>
        </RelativeLayout>
        <ListView
            android:id="@+id/LocationsList"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1" />
        <include
            android:id="@+id/bottomtoolbar"
            layout="@layout/toolbarbottom"
            android:layout_weight="0" />
    </LinearLayout>
</RelativeLayout>

在您的OnCreate()方法中嘗試:

protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Main);
            Window.SetSoftInputMode(SoftInput.AdjustPan); // also,you can try this "SoftInput.AdjustNothing"
//other stuff and etc
       }

軟鍵盤將覆蓋您的項目。
請享用!

轉到AndroidManifest Activity代碼中,將softinputType設置為AdjustPan

暫無
暫無

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

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