android - 软键盘弹出时标题栏隐藏

标签 android android-layout android-emulator android-widget android-manifest

我有一个自定义标题栏,所以我希望当用户在登录 Activity 中键入用户名和密码时,标题栏不应隐藏。但是,不幸的是它确实被隐藏了。我尝试使用 android:windowSoftInputMode= "adjustPan 但标题栏仍然隐藏。

So, how can I show both Title Bar and Softkeyboard?

这是我的截图,

This is my Login Activity

enter image description here

This is when I click on the EditText and the Title Bar gets Hide.

enter image description here

This is my xml for Login Activity.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/white">

    <TableLayout android:id="@+id/tbl_layout" 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:layout_marginRight="5dip"
        android:layout_marginLeft="5dip" android:layout_centerInParent="true">
        <TableRow android:weightSum="10">
            <TextView android:layout_weight="3" android:layout_width="0dp"
                android:layout_height="wrap_content" android:text="Username:"
                android:textColor="@color/dark_purple" />
            <EditText android:id="@+id/et_username" 
                android:layout_weight="7" android:layout_width="0dp"
                android:layout_height="wrap_content" android:hint="Username"
                android:singleLine="true"
                android:background="@drawable/edit_text_select"
                android:padding="8dip"
                 />
        </TableRow>

        <TableRow android:weightSum="10" android:layout_marginTop="10dip">
            <TextView android:layout_weight="3" android:layout_width="0dp"
                android:layout_height="wrap_content" android:text="Password:"
                android:textColor="@color/dark_purple" />
            <EditText android:id="@+id/et_password" 
                android:layout_weight="7" android:layout_width="0dp"
                android:layout_height="wrap_content" android:hint="Password"
                android:singleLine="true" 
                android:password="true"
                android:padding="8dip"
                android:background="@drawable/edit_text_select"/>
        </TableRow>
    </TableLayout>

    <LinearLayout android:layout_below="@id/tbl_layout" 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:gravity="right"
        android:layout_marginTop="10dip">
        <Button android:id="@+id/btn_login" 
            android:layout_height="wrap_content"
            android:layout_width="wrap_content" android:padding="15dp"
            android:text="Login" android:layout_marginRight="15dip"
            android:onClick="myOnClick"
            android:textColor="@android:color/white"
            android:background="@color/dark_purple"/>
    </LinearLayout>

</RelativeLayout>

最佳答案

我相信您已经在一个 RelativeLayout 中获取了所有 View 。

此外,如果您采用了 ScrollView,则将标题栏 TextView 放在 ScrollView 之外。我遇到了同样的问题,并通过这个技巧解决了。

如果您在此处发布 XML 布局,那么可以很好地纠正确切的问题。

关于android - 软键盘弹出时标题栏隐藏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7859492/

相关文章:

android - 如何设置已经运行的 Activity ,当用户点击主屏幕上的应用程序图标时

android - 如何在android中获取内部SD卡存储和外部(移除)SD卡存储以及系统存储和可用内存状态?

android - Firestore 更新查询未执行

android - 在 Android 中定位 subview

android - 更改 Android Studio 模拟器的语言环境

visual-studio - 无法加载android sdk实例。请检查您的互联网连接

Android 多行 TextView,检查文本是否适合,或者检查 TextView 是否已满

android - 无法从 Android 中的首选项中获取项目

c# - Android View 对象复用--防止View重现时显示旧尺寸

android - 一个接一个地对齐动态 TextView