24

私は、テキストビューと2つの編集テキストの後に単純なアクティビティを持っています。入力を開始すると、ソフトキーボードがレイアウトをプッシュしてアクションバーを隠すので、テキストを選択/コピー/貼り付けすることはできません。ソフトキーボード非表示のアクションバー

私の活動は次のようになります。

Normal activity view

私は入力を開始すると、アクションバーが非表示に取得し、このような - そしてもっと重要なのは、通常のコピーペーストバーにもかかわらず、不足していることに注意してくださいテキストが強調表示されています:

Missing action bar and the copy/paste bar

私はアクションバーが非表示にしないことを確認するために何ができますか?

  • 私はSOから(スクロールビューを使用するなど)いくつかのヒントを試しましたが、どれもうまくいきませんでした。
  • アプリは、引き出しアクティビティでAndroidスタジオ1.4.1ウィザードを使用して作成されます。
  • 私の活動の中で私はadjustPanを使用しています。私はadjustResizeを使いたくありません。

    android:windowSoftInputMode="stateAlwaysHidden|adjustPan"

私の活動はここにある:

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/navigation_drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:openDrawer="start"> 

    <android.support.design.widget.CoordinatorLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fitsSystemWindows="true" 
     tools:context=".MainActivity"> 

     <android.support.design.widget.AppBarLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:theme="@style/app_theme.app_bar_overlay"> 

      <android.support.v7.widget.Toolbar 
       android:id="@+id/toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="?attr/actionBarSize" 
       android:background="?attr/colorPrimary" 
       app:popupTheme="@style/app_theme.popup_overlay" /> 

     </android.support.design.widget.AppBarLayout> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_margin="@dimen/activity_margin" 
      android:fillViewport="true" 
      android:orientation="vertical" 
      app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_weight="0.5" 
       android:background="@android:color/darker_gray" 
       android:text="My holiday story here." /> 

      <View 
       android:layout_width="match_parent" 
       android:layout_height="@dimen/activity_margin" /> 

      <EditText 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginBottom="@dimen/gap_normal" 
       android:gravity="top" 
       android:text="My Holiday in Europe" /> 

      <EditText 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_weight="0.5" 
       android:gravity="top" 
       android:text="My holiday story is blah blah blah blah blah blah blah blah blah..." /> 

     </LinearLayout> 


    </android.support.design.widget.CoordinatorLayout> 

    <com.magicparcel.app.mysampleapp.ui.CustomNavigationView 
     android:id="@+id/navigation_view" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:fitsSystemWindows="true" 
     app:headerLayout="@layout/navigation_drawer_header" 
     app:itemIconTint="@color/app_grey_500" 
     app:menu="@menu/drawer_main" /> 

</android.support.v4.widget.DrawerLayout> 
+0

これを試してくださいhttp://stackoverflow.com/questions/8228514/keyboard-layout-hiding-android-action-bar – MHossein

+0

ありがとうございますが、adjustResizeではなくadjustPanを使用する必要があります。 – henry000

+0

AppBarLayout以外のScrollViewですべてのビューをラップしてみましたか? –

答えて

6

てみツールバーのapp:layout_collapseMode="pin"を追加することにより、

<android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="?attr/colorPrimary" 
      app:layout_collapseMode="pin" 
      app:popupTheme="@style/app_theme.popup_overlay" /> 

とEDITTEXT Set android:textIsSelectable="true"にコピー/貼り付けを可能にするための

は、より多くのを見てに

+0

こんにちは。 EditTextフィールドの上にある他のビューの場合はどうすればいいですか。例えば。 EditTextの上にいくつかのレイアウトがあり、adjustPanを使いたいと思っています。この場合、EditTextを選択している間、上のすべてのビューは上に移動し、一部は(ActionBarのように)非表示になります。 EditTextの上のいくつかのレイアウトを選択して保存し、他のものを上に移動させるにはどうすればいいですか? – GensaGames

+0

私はあなたが何を意味するかを知っていませんでした**私は何をすべきですか、選択時にEditTextの上のレイアウトを保存し、 –

0

AppBarLayout内にツールバーを追加し、AppBarOverLayテーマとPopOverlayテーマを追加します。

<android.support.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/AppTheme.AppBarOverlay"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="@color/colorPrimary" 
      app:popupTheme="@style/AppTheme.PopupOverlay"> 

     </android.support.v7.widget.Toolbar> 
</android.support.design.widget.AppBarLayout> 

のstyles.xml

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> 

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> 
0

STEP-1:各ビューからfitsSystemWindow属性を削除し、マニフェストのアクティビティタグに追加します。

ステップ-2app:layout_behavior="@string/appbar_scrolling_view_behavior"リニアレイアウトからこのラインを削除します。これは上のアクションバーを実際に押しているコードです。

これらの2つのステップは私の問題を解決しました。

関連する問題