我有一个自定义标题栏,所以我希望当用户在登录 Activity 中键入用户名和密码时,标题栏不应隐藏。但是,不幸的是它确实被隐藏了。我尝试使用 android:windowSoftInputMode= "adjustPan
但标题栏仍然隐藏。
So, how can I show both Title Bar and Softkeyboard?
这是我的截图,
This is my Login Activity
This is when I click on the EditText and the Title Bar gets Hide.
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/