テキストエリアがあり、その「OK」と「キャンセル」ボタンまであります。テキスト領域のキーボードをクリックすると、テキスト領域にフォーカスが表示され、ボタンがキーボードの後ろに隠れます。
テキスト領域がフォーカスされたときに少しスクロールし、テキスト領域IDが選択されている間は下のボタンも表示したい。
私は自分でそれを修正しました:D以下はコードです
テキストフィールドがフォーカスを取得したときに、次のメソッドを呼び出しました
private final void focusOnButtons(){
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
ScrollView sv = (ScrollView)findViewById(R.id.scrl);
sv.scrollTo(0, sv.getBottom());
}
},1000);
}
ScrollView で既存のレイアウトをラップしてみてください:
https://developer.android.com/reference/android/widget/ScrollView.html
レイアウト xml ファイルは次のようになります。
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ScrollView01" android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<EditText android:text="@string/hello" android:id="@+id/EditText01"
android:layout_width="wrap_content" android:layout_height="wrap_content">
</EditText>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button android:text="@+id/Button01" android:id="@+id/Button01"
android:layout_width="wrap_content" android:layout_height="wrap_content">
</Button>
<Button android:text="@+id/Button02" android:id="@+id/Button02"
android:layout_width="wrap_content" android:layout_height="wrap_content">
</Button>
</LinearLayout>
</LinearLayout>
</ScrollView>
コメントへの返信:
このページをチェックしてみてください:
https://developer.android.com/training/keyboard-input/index.html
Scrollview の外にボタンを移動しandroid:windowSoftInputMode="adjustResize"
、アクティビティを設定することで、必要な結果が得られると思います。