动作栏隐藏而不回来

时间:2018-03-22 12:49:29

标签: android android-fragments tabs android-actionbar

在我的android项目中,操作栏隐藏了,我无法使用侧抽屉中的菜单。我正在使用片段。只有当我尝试在 DECODE片段标签中的密码字段中输入密码时才会发生这种情况。但是在 ENCODE片段中,这种情况并没有发生并且运行良好。实际上,ActionBar正在上升,但当键盘隐藏时,它不会下降。这是我的 DECODE片段

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

 <FrameLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="@dimen/load_image_layout_margin_top"
    android:background="@drawable/layout_border">

    <ImageView
        android:id="@+id/loadDecodeImage"
        android:layout_width="match_parent"
        android:layout_height="@dimen/load_image_decode"
        android:gravity="center"
        android:paddingTop="2sp"
        android:contentDescription="@string/description_upload_image"
        android:adjustViewBounds ="true"
        android:scaleType="centerCrop" />

    <TextView
        android:id="@+id/imageTextDecodeMessage"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="bottom|center"
        android:drawableStart="@drawable/ic_open_image"
        android:gravity="center"
        android:text="@string/description_upload_image"
        android:textAllCaps="true"
        android:textColor="@color/colorPrimary"
        android:textSize="@dimen/text_load_image_size" />
 </FrameLayout>

 <android.support.design.widget.TextInputLayout
    android:id="@+id/decodePasswordLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="12sp"
    android:layout_marginRight="12sp"
    android:layout_marginTop="12sp"
    app:passwordToggleEnabled="true">

    <android.support.design.widget.TextInputEditText
        android:textColor="@color/colorPrimaryDark"
        android:id="@+id/passwordToDecode"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="@string/password_to_decode_hint"
        android:maxLength="16"
        android:inputType="textPassword"/>
 </android.support.design.widget.TextInputLayout>

 <LinearLayout android:layout_width="match_parent"
    android:orientation="vertical"
    android:layout_height="0dp"
    android:layout_weight="1.0">

    <Button
        android:id="@+id/decodeButton"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="8sp"
        android:layout_marginBottom="10sp"
        android:layout_marginLeft="12sp"
        android:layout_marginRight="12sp"
        android:background="@drawable/button_background"
        android:text="@string/decode"
        android:textColor="@color/colorButtonText"
        android:textSize="@dimen/button_text_size" />

 </LinearLayout>

</LinearLayout>

这是AndroidManifest.xml文件:

 <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.stegano.strenggeheim">

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature
    android:name="android.hardware.camera.any"
    android:required="true" />
<uses-feature
    android:name="android.hardware.camera.autofocus"
    android:required="false" />

  <application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:largeHeap="true"
    android:theme="@style/MyMaterialTheme">
    <activity
        android:name=".activity.MainActivity"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="adjustResize"
        android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".activity.AboutUsActivity"
        android:screenOrientation="portrait"
        android:label="@string/title_activity_about_us"
        android:theme="@style/Theme.AppCompat.Light.DarkActionBar"
        android:parentActivityName=".activity.MainActivity" >
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value=".activity.MainActivity"
            />
    </activity>
    <activity
        android:name=".activity.TextDialogActivity"
        android:screenOrientation="portrait"
        android:theme="@style/Theme.AppCompat.Dialog"
        android:label="Secret Message">
    </activity>
    <activity
        android:name=".activity.SettingsActivity"
        android:screenOrientation="portrait"
        android:label="Settings"
        android:theme="@style/Theme.AppCompat.Light.DarkActionBar"
        android:parentActivityName=".activity.MainActivity">
    </activity>
    <provider
        android:name="android.support.v4.content.FileProvider"
        android:authorities="${applicationId}.provider"
        android:exported="false"
        android:grantUriPermissions="true">
        <meta-data
            android:name="android.support.FILE_PROVIDER_PATHS"
            android:resource="@xml/provider_paths"/>
    </provider>
  </application>

 </manifest>

这是我项目的截图:

enter image description here

1 个答案:

答案 0 :(得分:0)

在您的 AndroidManifest.xml 中删除您的DrawerActivity adjustPan,请使用adjustResize

只需替换此

android:windowSoftInputMode="adjustPan"

使用此

android:windowSoftInputMode="adjustResize"

一定会对你有所帮助。