質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
XML

XMLは仕様の1つで、マークアップ言語群を構築するために使われています。

Android

Androidは、Google社が開発したスマートフォンやタブレットなど携帯端末向けのプラットフォームです。 カーネル・ミドルウェア・ユーザーインターフェイス・ウェブブラウザ・電話帳などのアプリケーションやソフトウェアをひとつにまとめて構成。 カーネル・ライブラリ・ランタイムはほとんどがC言語/C++、アプリケーションなどはJavaSEのサブセットとAndroid環境で書かれています。

デザイン

プログラミングでのデザインとは、プログラムの構成や、使用の信頼性・持続性・正確性・利便性の目標達成にはどうするのがベストなのか特定の選択を行うことです。

Q&A

解決済

1回答

11186閲覧

ソフトウェアキーボードが出てきた際にフッターのボタンを上げない方法

type23

総合スコア18

XML

XMLは仕様の1つで、マークアップ言語群を構築するために使われています。

Android

Androidは、Google社が開発したスマートフォンやタブレットなど携帯端末向けのプラットフォームです。 カーネル・ミドルウェア・ユーザーインターフェイス・ウェブブラウザ・電話帳などのアプリケーションやソフトウェアをひとつにまとめて構成。 カーネル・ライブラリ・ランタイムはほとんどがC言語/C++、アプリケーションなどはJavaSEのサブセットとAndroid環境で書かれています。

デザイン

プログラミングでのデザインとは、プログラムの構成や、使用の信頼性・持続性・正確性・利便性の目標達成にはどうするのがベストなのか特定の選択を行うことです。

0グッド

0クリップ

投稿2017/04/04 02:09

###前提・実現したいこと

  • フッターにボタンを表示させたい
  • EditTextにフォーカスが当たった際にフッターのボタンを上げたくない。

EditTextにフォーカスが当たりソフトウェアキーボードが表示された際に、下部に固定しておきたい保存ボタンがソフトウェアの上に表示されてしまいます。
フッターのボタンが2段になる場合もあるため、保存ボタンをソフトウェアキーボードの裏に隠したいです。
どの様にレイアウトを組めばよいでしょうか?

###発生している問題・エラーメッセージ
保存ボタンをキーボードの裏に隠したい

###該当のソースコード

xml

1<?xml version="1.0" encoding="utf-8"?> 2<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 xmlns:tools="http://schemas.android.com/tools" 4 android:id="@+id/activity_settigs" 5 android:layout_width="match_parent" 6 android:layout_height="match_parent" 7 android:orientation="vertical" 8 tools:context=".SettingsActivity"> 9 10 <ScrollView 11 android:layout_width="match_parent" 12 android:layout_height="0dp" 13 android:layout_weight="1"> 14 15 <LinearLayout 16 android:layout_width="match_parent" 17 android:layout_height="match_parent" 18 android:orientation="vertical"> 19 20 <TextView 21 android:layout_width="match_parent" 22 android:layout_height="wrap_content" 23 android:text="設定1" /> 24 25 <EditText 26 android:id="@+id/setting1" 27 android:layout_width="match_parent" 28 android:layout_height="wrap_content" /> 29 30 <TextView 31 android:layout_width="match_parent" 32 android:layout_height="wrap_content" 33 android:text="設定2" /> 34 35 <EditText 36 android:id="@+id/setting2" 37 android:layout_width="match_parent" 38 android:layout_height="wrap_content" /> 39 40 <TextView 41 android:layout_width="match_parent" 42 android:layout_height="wrap_content" 43 android:text="設定3" /> 44 45 <EditText 46 android:id="@+id/setting3" 47 android:layout_width="match_parent" 48 android:layout_height="wrap_content" /> 49 50 <TextView 51 android:layout_width="match_parent" 52 android:layout_height="wrap_content" 53 android:text="設定4" /> 54 55 <EditText 56 android:id="@+id/setting4" 57 android:layout_width="match_parent" 58 android:layout_height="wrap_content" /> 59 </LinearLayout> 60 </ScrollView> 61 62 <Button 63 android:layout_width="match_parent" 64 android:layout_height="wrap_content" 65 android:text="保存" /> 66</LinearLayout>

###試したこと
該当のlayoutのxmlとAndroidManifest.xmlをいじって見ましたが

xml

1 <Button 2 android:layout_width="match_parent" 3 android:layout_height="wrap_content" 4 android:gravity="bottom" 5 android:text="保存" />

xml

1 <activity 2 android:name=".SettingsActivity" 3 android:screenOrientation="portrait" 4 android:windowSoftInputMode="adjustResize" />

###補足情報(言語/FW/ツール等のバージョンなど)
Kitkatの実機とlolipoのエミュレータで確認中。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

android:windowSoftInputMode="adjustResize"
は逆にリサイズされて表示されちゃうので切ってください。

それでもおかしいならrootのレイアウトに
android:fitsSystemWindows="true"
あたりも必要かもしれません。

なお、Kitkat以降でandroid:windowTranslucentStatus=true
でフルスクリーンにしてしまうとadjustResize関連はおかしくなるようです。
https://code.google.com/p/android/issues/detail?id=63777


更新
ちょっとadjust周りを調べてみました。

android:windowSoftInputMode="adjustPan"

を利用すればいけそうです(Android6で確認済)。
adjustNothingというのも実は隠れてありますが。ドキュメントにはないようなので上のほうがいいかと。

AndroidManifestに対して以下な感じでしょうか。

xml

1 <activity 2 android:name=".SettingsActivity" 3 android:screenOrientation="portrait" 4 android:windowSoftInputMode="stateVisible|adjustPan" /> 5

レイアウトは編集しないです。
stateVisibleは最初にフォーカスあたってInputが表示されたくない場合は消してみてください。

投稿2017/04/04 03:39

編集2017/04/04 06:01
uniko

総合スコア448

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

type23

2017/04/04 05:02

ありがとうございます。 android:windowSoftInputMode="adjustResize" を削除してstyles.xmlに <item name="android:fitsSystemWindows">true</item> を追加してみましたが、結果は同じでした。 AndroidStudioで新規作成した時に生成されるstyles.xmlをそのまま使ってます。 ```xml <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> <item name="android:fitsSystemWindows">true</item> </style> ``` (コメント蘭はMarkDownが使えないんだっけ??)
type23

2017/04/04 05:04

AndroidManifest.xmlで指定しているThemaであることは確認してます。 <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme">
uniko

2017/04/04 05:05

ちょっと手元にPCがないので実際に確認できてはいませんが、themeにandroid:fitsSystemWindowsは設定しないほうがよいです。トースト等がおかしくなります。
type23

2017/04/04 06:03

前の質問から何度もありがとうございます。 AndroidManifest.xmでapplicationや該当のactivityにもandroid:fitsSystemWindows="true"を設定しましたが、上手く行かないですね。。 画面設計を修正する案も検討したほうが良さそうな気がしてきました。 <activity android:name=".SettingsActivity" android:fitsSystemWindows="true" android:screenOrientation="portrait" />
uniko

2017/04/04 06:12

おや?追記した内容でもできませんか?一応実機のOS5.0でも隠れました。 あとandroid:fitsSystemWindowsは、ManifestではなくLayout側にということです。 具体的にはLinearLayoutのとこにつけたりって意味です。
type23

2017/04/04 06:24

すみません。追記していただいた箇所に先程気が付き試しました。 Manifestに追記したところ思うような動作になりました。 本当に何度も、ありがとうございます! 今は画像系の処理を実装しているので、また質問させて頂くことになりそうです。 もしお見かけの際はチョロっと質問を読んでいただけると助かります。 なお、android:fitsSystemWindows="true"は、Manifestでもactivityが読み込んでいるlayoutファイルのLinearLayoutでも試しましたがダメでした。
uniko

2017/04/04 06:28

はい。ようございました。 android:fitsSystemWindowsがダメというのがどういった状況なのかちょっとわかってないのですが、なぜThemeはやめてといったかというと http://qiita.com/pside/items/454293288dc3684ed1fc にあるような形になるからでございます。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問