瀑布流+实现搜索界面以及功能

本文展示了如何在Android应用中创建一个带有瀑布流布局的搜索界面。通过使用`include`方法整合多个布局文件,如activity_main.xml、搜索框布局、最近搜索布局等,实现了界面构建。主要代码集中在MainActivity,布局完成后,搜索功能的实现变得简单。文中还提到了添加圆角表框的细节处理。
摘要由CSDN通过智能技术生成

先看一下效果图

 

就是这样,其实不难,只要布局多了点,MainActivity里的代码很少,只要布局整好了,那么这个搜索界面很快就会实现。

我标红的这两行代码,使用的include方法,可以得到别的布局,添加到主布局文件中,大家可以试一下。

我先展示一下我的布局:

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:background="#fff"
    tools:context=".MainActivity">
    <include layout="@layout/horizontal_item"/>

    <include layout="@layout/horizontal_item_one"/>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="100dp">

        <com.example.library.AutoFlowLayout
            android:id="@+id/auto_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            ></com.example.library.AutoFlowLayout>

        <RelativeLayout
            android:id="@+id/re1"
            android:layout_below="@id/auto_layout"
            android:layout_width="match_parent"
            android:layout_height="100dp"
            android:layout_marginTop="35dp">
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="搜索发现"
                android:textStyle="bold"
                android:layout_marginTop="6dp"
                android:layout_marginLeft="5dp"
                android:textSize="16dp"/>

            <TextView
                android:layout_marginTop="40dp"
                android:layout_marginLeft="8dp"
                android:layout_width="75dp"
                android:paddingTop="4dp"
                android:gravity="center_horizontal"
              
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值