调整大小 属性 不起作用
Adjust Resize property does not work
我的问题如下-
我的 activity 中有一个 webview
,下面是 webview
,线性布局显示底部的页脚图标。
现在,当软键盘弹出时,我希望整个 activity 调整调整大小,但我不希望页脚图标倒置,我希望它们固定在底部。
AdjustPan
和 adjustNothing
对我不起作用,因为我的网页包含 editTexts
用户名和密码,这两个属性都使它们留在软键盘后面。
感谢任何帮助。
编辑
我希望在弹出软键盘时,线性布局中的浮动按钮不会出现。
我的 Xml 如下 -
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/rel_parent"
tools:context=".Login">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/rel_web">
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/wv_main"
android:layout_weight="1"
android:isScrollContainer="false">
</WebView>
<ProgressBar
android:id="@+id/progressBar1"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_centerVertical="true"
android:layout_centerInParent="true"/>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/offline_mode"
android:layout_centerInParent="true"
android:background="#ffffff"
android:visibility="gone">
<ImageView
android:layout_width="90dp"
android:layout_height="90dp"
android:src="@drawable/offline"
android:id="@+id/im_offline" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textSize="18sp"
android:text="Offline"
android:layout_marginTop="10dp"
android:layout_centerHorizontal="true"
android:layout_below="@+id/im_offline"/>
</RelativeLayout>
<LinearLayout
android:id="@+id/ll_buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="47px"
android:gravity="center_horizontal"
android:visibility="visible"
android:weightSum="1">
<LinearLayout
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_weight="0.80"
android:weightSum="11.5">
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:clickable="true"
android:onClick="openHome"
android:src="@drawable/home_icon"
android:scaleType="centerInside"/>
<View
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_weight="0.5" />
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:clickable="true"
android:onClick="openHeadphone"
android:src="@drawable/headphone_icon" />
<View
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_weight=".5" />
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:clickable="true"
android:onClick="openEmail"
android:src="@drawable/email_icon" />
<View
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_weight=".5" />
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:clickable="true"
android:onClick="openFb"
android:src="@drawable/fb_icon" />
<View
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_weight=".5" />
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:clickable="true"
android:onClick="openInsta"
android:src="@drawable/instagram_icon" />
<View
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_weight=".5" />
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:clickable="true"
android:onClick="openYoutube"
android:src="@drawable/youtube" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
我已经检查过我的方式,我只是删除 android:windowSoftInputMode="adjustResize"
并添加到父级 Scrollview
。试试下面的代码:
代码
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/rel_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:id="@+id/rel_web"
android:layout_width="match_parent"
android:layout_height="match_parent">
<WebView
android:id="@+id/wv_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:isScrollContainer="false" />
<ProgressBar
android:id="@+id/progressBar1"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_centerVertical="true" />
<RelativeLayout
android:id="@+id/offline_mode"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:background="#ffffff"
android:visibility="gone">
<ImageView
android:id="@+id/im_offline"
android:layout_width="90dp"
android:layout_height="90dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/im_offline"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:text="Offline"
android:textColor="#000000"
android:textSize="18sp" />
</RelativeLayout>
<LinearLayout
android:id="@+id/ll_buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="10dp"
android:gravity="center_horizontal"
android:visibility="visible"
android:weightSum="1">
<LinearLayout
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_weight="0.80"
android:weightSum="11.5">
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:clickable="true"
android:onClick="openHome"
android:scaleType="centerInside"
android:src="@mipmap/ic_launcher" />
<View
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_weight="0.5" />
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:clickable="true"
android:onClick="openHeadphone"
android:src="@mipmap/ic_launcher" />
<View
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_weight=".5" />
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:clickable="true"
android:onClick="openEmail"
android:src="@mipmap/ic_launcher" />
<View
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_weight=".5" />
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:clickable="true"
android:onClick="openFb"
android:src="@mipmap/ic_launcher" />
<View
android:layout_width="0dp"
android:layout_height="29dp"
android:layout_weight=".5" />
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:clickable="true"
android:onClick="openInsta"
android:src="@mipmap/ic_launcher" />
<View
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_weight=".5" />
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:clickable="true"
android:onClick="openYoutube"
android:src="@mipmap/ic_launcher" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
这是我检查过的屏幕截图。
截图一张
截图二
我向下滚动后的屏幕截图三
我的问题如下-
我的 activity 中有一个 webview
,下面是 webview
,线性布局显示底部的页脚图标。
现在,当软键盘弹出时,我希望整个 activity 调整调整大小,但我不希望页脚图标倒置,我希望它们固定在底部。
AdjustPan
和 adjustNothing
对我不起作用,因为我的网页包含 editTexts
用户名和密码,这两个属性都使它们留在软键盘后面。
感谢任何帮助。
编辑
我希望在弹出软键盘时,线性布局中的浮动按钮不会出现。 我的 Xml 如下 -
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/rel_parent"
tools:context=".Login">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/rel_web">
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/wv_main"
android:layout_weight="1"
android:isScrollContainer="false">
</WebView>
<ProgressBar
android:id="@+id/progressBar1"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_centerVertical="true"
android:layout_centerInParent="true"/>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/offline_mode"
android:layout_centerInParent="true"
android:background="#ffffff"
android:visibility="gone">
<ImageView
android:layout_width="90dp"
android:layout_height="90dp"
android:src="@drawable/offline"
android:id="@+id/im_offline" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textSize="18sp"
android:text="Offline"
android:layout_marginTop="10dp"
android:layout_centerHorizontal="true"
android:layout_below="@+id/im_offline"/>
</RelativeLayout>
<LinearLayout
android:id="@+id/ll_buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="47px"
android:gravity="center_horizontal"
android:visibility="visible"
android:weightSum="1">
<LinearLayout
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_weight="0.80"
android:weightSum="11.5">
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:clickable="true"
android:onClick="openHome"
android:src="@drawable/home_icon"
android:scaleType="centerInside"/>
<View
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_weight="0.5" />
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:clickable="true"
android:onClick="openHeadphone"
android:src="@drawable/headphone_icon" />
<View
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_weight=".5" />
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:clickable="true"
android:onClick="openEmail"
android:src="@drawable/email_icon" />
<View
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_weight=".5" />
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:clickable="true"
android:onClick="openFb"
android:src="@drawable/fb_icon" />
<View
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_weight=".5" />
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:clickable="true"
android:onClick="openInsta"
android:src="@drawable/instagram_icon" />
<View
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_weight=".5" />
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:clickable="true"
android:onClick="openYoutube"
android:src="@drawable/youtube" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
我已经检查过我的方式,我只是删除 android:windowSoftInputMode="adjustResize"
并添加到父级 Scrollview
。试试下面的代码:
代码
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/rel_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:id="@+id/rel_web"
android:layout_width="match_parent"
android:layout_height="match_parent">
<WebView
android:id="@+id/wv_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:isScrollContainer="false" />
<ProgressBar
android:id="@+id/progressBar1"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_centerVertical="true" />
<RelativeLayout
android:id="@+id/offline_mode"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:background="#ffffff"
android:visibility="gone">
<ImageView
android:id="@+id/im_offline"
android:layout_width="90dp"
android:layout_height="90dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/im_offline"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:text="Offline"
android:textColor="#000000"
android:textSize="18sp" />
</RelativeLayout>
<LinearLayout
android:id="@+id/ll_buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="10dp"
android:gravity="center_horizontal"
android:visibility="visible"
android:weightSum="1">
<LinearLayout
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_weight="0.80"
android:weightSum="11.5">
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:clickable="true"
android:onClick="openHome"
android:scaleType="centerInside"
android:src="@mipmap/ic_launcher" />
<View
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_weight="0.5" />
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:clickable="true"
android:onClick="openHeadphone"
android:src="@mipmap/ic_launcher" />
<View
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_weight=".5" />
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:clickable="true"
android:onClick="openEmail"
android:src="@mipmap/ic_launcher" />
<View
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_weight=".5" />
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:clickable="true"
android:onClick="openFb"
android:src="@mipmap/ic_launcher" />
<View
android:layout_width="0dp"
android:layout_height="29dp"
android:layout_weight=".5" />
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:clickable="true"
android:onClick="openInsta"
android:src="@mipmap/ic_launcher" />
<View
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_weight=".5" />
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:clickable="true"
android:onClick="openYoutube"
android:src="@mipmap/ic_launcher" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
这是我检查过的屏幕截图。
截图一张
截图二
我向下滚动后的屏幕截图三