【问题标题】:Title Bar gets hide when Softkeyboard pops up弹出软键盘时标题栏隐藏
【发布时间】:2011-12-13 03:43:37
【问题描述】:

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

那么,如何同时显示标题栏和软键盘?

这是我的屏幕截图,

这是我的登录活动

这是当我点击 EditText 并且标题栏被隐藏时。

这是我用于登录活动的 xml。

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

【问题讨论】:

  • 作为一个高效的 stackoverflow 用户,当您遇到问题时,您应该在此处发布 XML 布局。

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


【解决方案1】:

我相信你已经在一个RelativeLayout中获得了所有的观点。

如果你选择了ScrollView,那么将Titlebar textview 放在ScrollView 之外。我遇到了同样的问题,并通过这个技巧解决了。

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

【讨论】:

  • 我现在发布了xml,但在此之前你的答案是什么,应该在评论部分。
  • 你在哪里取了Title TextView?是在 ViewStub 中还是在其他地方?
  • 我没有使用 ScrollView,因为这里不需要滚动。
  • 我从你的回答中得到了提示,关于将我的布局放在 scrollView 中,它对我有用。谢谢。
猜你喜欢
  • 2016-02-01
  • 1970-01-01
  • 2014-12-13
  • 2016-07-03
  • 1970-01-01
  • 2012-10-28
  • 1970-01-01
  • 2019-06-08
  • 1970-01-01
相关资源
最近更新 更多