问题
I have designed layout by taking the reference from this and code for the same is below.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ll_parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/action_bar_color"
android:minHeight="?attr/actionBarSize">
<TextView
android:id="@+id/txt_user_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginLeft="@dimen/image_margin_left"
android:text="@string/app_name"
android:textColor="@android:color/black"
android:textSize="@dimen/login_txt_size" />
<ImageView
android:id="@+id/img_refresh"
android:layout_width="@dimen/logo_image_w"
android:layout_height="@dimen/logo_image_h"
android:layout_gravity="right"
android:layout_marginLeft="@dimen/image_margin_left"
android:background="@drawable/custom_image_click"
android:src="@drawable/ic_action_refresh" />
<ImageView
android:id="@+id/img_setting"
android:layout_width="@dimen/logo_image_w"
android:layout_height="@dimen/logo_image_h"
android:layout_gravity="right"
android:layout_marginLeft="@dimen/image_margin_left"
android:background="@drawable/custom_image_click"
android:src="@drawable/ic_action_settings" />
<ImageView
android:id="@+id/img_wifi"
android:layout_width="@dimen/logo_image_w"
android:layout_height="@dimen/logo_image_h"
android:layout_gravity="right"
android:layout_marginLeft="@dimen/image_margin_left"
android:background="@drawable/custom_image_click"
android:src="@drawable/ic_wifi_on"
android:tint="@color/button_theme_color" />
</android.support.v7.widget.Toolbar>
<TextView
android:id="@+id/tv_home_networkStatus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#003b60"
android:gravity="center_horizontal"
android:padding="10dp"
android:text="Medium Text"
android:textColor="#FFFF0000"
android:textSize="20sp"
android:visibility="visible" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:fillViewport="true"
android:gravity="center">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="10">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="50dp"
android:src="@drawable/logo_login" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="100dp"
android:layout_marginRight="100dp"
android:layout_weight="6"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/round_masjid_corner"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20dp"
android:src="@drawable/masjid" />
<View
android:layout_width="5dp"
android:layout_height="match_parent"
android:background="@drawable/user_sep" />
<EditText
android:id="@+id/edt_clientid"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:background="@null"
android:hint="Client ID"
android:inputType="number"
android:singleLine="true"
android:textColor="#FFFFFF"
android:textColorHint="#FFFFFF"
android:textSize="35sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:background="@drawable/round_kiosk_corner"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@null"
android:padding="20dp"
android:src="@drawable/tablet" />
<View
android:layout_width="5dp"
android:layout_height="match_parent"
android:background="@drawable/pass_sep" />
<EditText
android:id="@+id/edt_device_code"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:background="@null"
android:hint="Device Code"
android:inputType="text"
android:singleLine="true"
android:textColor="#FFFFFF"
android:textColorHint="#FFFFFF"
android:textSize="35sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal">
<Button
android:id="@+id/btn_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:background="@drawable/custom_button_frag_menu"
android:padding="20dp"
android:text="Login"
android:textAllCaps="false"
android:textColor="#FFFFFF"
android:textSize="35sp" />
<Button
android:id="@+id/btn_cancel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:background="@drawable/custom_button_frag_menu"
android:padding="20dp"
android:text="Cancel"
android:textAllCaps="false"
android:textColor="#FFFFFF"
android:textSize="35sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
And code of manifest is below
<activity android:name=".activity.LoginActivity"
android:theme="@style/AppTheme.NoActionBar"
android:screenOrientation="landscape"
android:windowSoftInputMode="adjustPan|adjustResize">
</activity>
But still it gives output like . When soft keyboard is appearing buttons are hiding below of the soft keyboard.I have tried by using adjustResize
as well as adjustPan
,but still no change in output.I have added ScrollView
too If anyone is having the solution please help
回答1:
Try this make ScrollView
as parent root layout like below code
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ll_parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/action_bar_color"
android:minHeight="?attr/actionBarSize">
<TextView
android:id="@+id/txt_user_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginLeft="@dimen/image_margin_left"
android:text="@string/app_name"
android:textColor="@android:color/black"
android:textSize="@dimen/login_txt_size" />
<ImageView
android:id="@+id/img_refresh"
android:layout_width="@dimen/logo_image_w"
android:layout_height="@dimen/logo_image_h"
android:layout_gravity="right"
android:layout_marginLeft="@dimen/image_margin_left"
android:background="@drawable/custom_image_click"
android:src="@drawable/ic_action_refresh" />
<ImageView
android:id="@+id/img_setting"
android:layout_width="@dimen/logo_image_w"
android:layout_height="@dimen/logo_image_h"
android:layout_gravity="right"
android:layout_marginLeft="@dimen/image_margin_left"
android:background="@drawable/custom_image_click"
android:src="@drawable/ic_action_settings" />
<ImageView
android:id="@+id/img_wifi"
android:layout_width="@dimen/logo_image_w"
android:layout_height="@dimen/logo_image_h"
android:layout_gravity="right"
android:layout_marginLeft="@dimen/image_margin_left"
android:background="@drawable/custom_image_click"
android:src="@drawable/ic_wifi_on"
android:tint="@color/button_theme_color" />
</android.support.v7.widget.Toolbar>
<TextView
android:id="@+id/tv_home_networkStatus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#003b60"
android:gravity="center_horizontal"
android:padding="10dp"
android:text="Medium Text"
android:textColor="#FFFF0000"
android:textSize="20sp"
android:visibility="visible" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="10">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="50dp"
android:src="@drawable/logo_login" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="100dp"
android:layout_marginRight="100dp"
android:layout_weight="6"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/round_masjid_corner"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20dp"
android:src="@drawable/masjid" />
<View
android:layout_width="5dp"
android:layout_height="match_parent"
android:background="@drawable/user_sep" />
<EditText
android:id="@+id/edt_clientid"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:background="@null"
android:hint="Client ID"
android:inputType="number"
android:singleLine="true"
android:textColor="#FFFFFF"
android:textColorHint="#FFFFFF"
android:textSize="35sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:background="@drawable/round_kiosk_corner"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@null"
android:padding="20dp"
android:src="@drawable/tablet" />
<View
android:layout_width="5dp"
android:layout_height="match_parent"
android:background="@drawable/pass_sep" />
<EditText
android:id="@+id/edt_device_code"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:background="@null"
android:hint="Device Code"
android:inputType="text"
android:singleLine="true"
android:textColor="#FFFFFF"
android:textColorHint="#FFFFFF"
android:textSize="35sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal">
<Button
android:id="@+id/btn_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:background="@drawable/custom_button_frag_menu"
android:padding="20dp"
android:text="Login"
android:textAllCaps="false"
android:textColor="#FFFFFF"
android:textSize="35sp" />
<Button
android:id="@+id/btn_cancel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:background="@drawable/custom_button_frag_menu"
android:padding="20dp"
android:text="Cancel"
android:textAllCaps="false"
android:textColor="#FFFFFF"
android:textSize="35sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
than apply android:windowSoftInputMode="adjustResize"
in manifest file to your activity
NOTE: - fullscreen mode doesn't resize
来源:https://stackoverflow.com/questions/47586564/layout-is-not-pushing-up-when-soft-keyboard-appears