我正在尝试创建一个打开外部网站的网络视图。问题是当我单击文本输入来输入文本时,键盘会打开,并将页面向上移动会导致文本输入消失。我必须手动向下滚动到文本输入。我没有尝试的方法。我在做什么错了?
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.app.webView.webView">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:screenOrientation="portrait"
android:supportsRtl="true"
android:windowSoftInputMode="adjustResize"
android:theme="@style/AppTheme.NoActionBar">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".WebActivity"
android:windowSoftInputMode="adjustResize"
android:theme="@style/webview">
</activity>
</application>
</manifest>
styles.xml
<style name="ToolbarStyle" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:background">@color/colorPrimaryDark</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
</style>
<style name="webview" parent="AppTheme.NoActionBar">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowFullscreen">false</item>
</style>
activity_web.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
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"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".WebActivity">
<include
android:id="@+id/toolbar"
layout="@layout/app_toolbar"
app:layout_anchorGravity="bottom|center"
>
</include>
<WebView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/toolbar"
app:layout_constraintStart_toEndOf="@id/toolbar"
android:layout_alignParentBottom="true"
android:focusable="true"
android:focusableInTouchMode="true"
/>
</android.support.constraint.ConstraintLayout>
app_toolbar.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:elevation="0dp"
app:theme="@style/ToolbarStyle">
<TextView
android:id="@+id/progressWifi"
android:layout_width="50dp"
android:layout_height="50dp"
/>
<TextView
android:id="@+id/tvBattery"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginStart="20dp"
/>
<TextView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginStart="20dp"
app:iiv_color="@android:color/holo_red_dark"
app:iiv_icon="gmd-print" />
</android.support.v7.widget.Toolbar>
WebActivity.java
public class WebActivity extends BaseActivity {
@BindView(R.id.toolbar) Toolbar toolbar;
@BindView(R.id.webview) WebView webView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web);
webView = findViewById(R.id.webview);
webView.getSettings().setJavaScriptEnabled(true);
//webView.getSettings().setUserAgentString("Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko/20100101Firefox/4.0");
webView.loadUrl("https://externalurl.com");
webView.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url) {
System.out.println("Page finished " + url);
}
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
});
}
}
}
答案 0 :(得分:0)
public function insertContact (Request $request) //
{
$model = App\InsertUser::create([
'firstname' => $request->firstname,
'lastname' => $request->lastname,
'email' => $request->email,
'telephone' => $request->telephone
]);
}