SearchView搜索栏 + Floatingactionbutton按键 - 简易浏览器

本文介绍了如何在Android应用中创建一个简易浏览器,重点在于使用SearchView作为搜索栏和FloatingActionButton作为操作按钮。通过布局代码解析,展示了如何设置SearchView的样式和功能,以及FloatingActionButton的配置,包括位置、颜色、图标和展开方向等。
摘要由CSDN通过智能技术生成

一、先上个效果图(万能的百度)。

二、准备工作:

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"
         
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值