当用户按下WebView中的某个字段时,我试图使布局向上滚动(当前键盘覆盖该字段)。我的布局文件如下:
<android.support.design.widget.CoordinatorLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/lFailed"
xmlns:ads="http://schemas.android.com/apk/res-auto"
>
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/b_gradient"
android:scaleType="centerCrop">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="80dp"
android:background="@drawable/b_gradient_toolbar_top"
app:layout_scrollFlags="scroll|enterAlwaysCollapsed"
app:popupTheme="@style/myPopUpTheme" />
<Space
android:id="@+id/sSpace"
android:layout_width="match_parent"
android:layout_height="100dp"
app:layout_scrollFlags="scroll|enterAlwaysCollapsed" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/b_gradient_toolbar_bottom"
android:gravity="bottom"
android:orientation="vertical"
android:paddingTop="26dp">
<TextView
android:id="@+id/tSafety"
style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:background="@android:color/transparent"
android:ellipsize="end"
android:fontFamily="sans-serif-smallcaps"
android:gravity="right"
android:paddingLeft="10dp"
android:shadowColor="@android:color/black"
android:shadowDx="2"
android:shadowDy="5"
android:shadowRadius="5"
android:singleLine="true"
android:text="Sub Title"
android:textAlignment="gravity"
android:textSize="12dp"
android:textStyle="bold" />
<ProgressBar
android:id="@+id/pProgress"
style="@android:style/Widget.Material.Light.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="100"
android:maxHeight="5dp"
android:minHeight="5dp"
android:progress="0"
android:theme="@android:style/Widget.Holo.Light.ProgressBar.Small" />
<TextView
android:id="@+id/tTitle"
style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/transparent_white"
android:ellipsize="end"
android:fontFamily="sans-serif-smallcaps"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp"
android:singleLine="true"
android:text="Site Title"
android:textColor="@android:color/black" />
<TextView
android:id="@+id/tSubTitle"
style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/transparent_white"
android:ellipsize="end"
android:fontFamily="sans-serif-smallcaps"
android:paddingBottom="5dp"
android:textColor="@android:color/black"
android:paddingLeft="10dp"
android:singleLine="true"
android:text="Sub Title"
android:textSize="12dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/transparent_white"
android:orientation="vertical"
android:paddingBottom="1dp"
android:paddingTop="1dp"
>
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adSize="SMART_BANNER"
ads:adUnitId="@string/admob_banner"></com.google.android.gms.ads.AdView>
</LinearLayout>
</LinearLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/nested_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="fill_vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
>
<WebView
android:id="@+id/wView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:fitsSystemWindows="true">
</WebView>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
我尝试了以下方法-但无济于事:
在onCreate上添加以下内容:getWindow()。setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
在清单中的“活动”中添加以下内容:android:windowSoftInputMode =“ stateHidden | adjustPan”和android:windowSoftInputMode =“ stateHidden | adjustResize”
有解决方案吗?