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