一、先上个效果图(万能的百度)。
二、准备工作:
1.要上网当然要有上网权限咯。
AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET"/>
2.Button的第三方库:
implementation 'com.getbase:floatingactionbutton:1.10.1'
三、先上布局代码,再解析:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_all"
tools:context=".MainActivity">
<WebView android:id="@+id/web_panel"
android:layout_below = "@id/search_bar"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<LinearLayout android:id="@+id/search_bar"
android:background="@color/yellow_FF7E14"
android:padding="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.SearchView
android:layout_marginEnd="70dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/search_shape"
app:queryHint="输入网址"
app:iconifiedByDefault="false"