亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

android頂部(toolbar)搜索框?qū)崿F(xiàn)代碼

 更新時(shí)間:2018年01月12日 09:27:35   作者:人言落日是天涯  
這篇文章主要介紹了android頂部(toolbar)搜索框?qū)崿F(xiàn)代碼,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧

APP中經(jīng)常會(huì)使用到搜索功能,那我們的搜索框該如何布局呢?下面咱們就看一下下面這個(gè)效果:

xml布局:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
                         xmlns:app="http://schemas.android.com/apk/res-auto"
                         android:id="@+id/main_content"
                         android:layout_width="match_parent"
                         android:layout_height="match_parent"
                         android:focusableInTouchMode="true"
                         android:fitsSystemWindows="true">

  <android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

    <TextView
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:padding="16dp"
      android:text="@string/large_text" />
  </android.support.v4.widget.NestedScrollView>

  <android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/ThemeOverlay.AppCompat.Dark">

    <android.support.v7.widget.Toolbar
      android:id="@+id/toolbar"
      android:layout_width="match_parent"
      android:layout_height="?attr/actionBarSize"
      android:background="@color/colorPrimary"
      app:layout_scrollFlags="scroll|enterAlways"
      app:title="標(biāo)題欄"
      app:navigationIcon="@mipmap/navigation_back_white"
      app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
      app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />

    <RelativeLayout
      android:id="@+id/search_layout"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_below="@+id/toolbar"
      android:background="@color/colorPrimary"
      android:padding="16dp">

      <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:drawableLeft="@android:drawable/ic_menu_camera"
        android:drawablePadding="22dp"
        android:drawableRight="@android:drawable/ic_menu_search"
        android:gravity="left|center"
        android:hint="請(qǐng)輸入搜索內(nèi)容"
        android:padding="10dp"
        android:textColorHint="@android:color/darker_gray" />
    </RelativeLayout>

  </android.support.design.widget.AppBarLayout>

</android.support.design.widget.CoordinatorLayout>

Activity直接引用布局即可:

public class StopSearchViewBelowToolbarActivity extends AppCompatActivity {

  @Override
  protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_stop_search_view_toolbar_layout);
  }
}

這里就是充分使用了CoordinatorLayout、AppBarLayout、NestedScrollView、Toolbar的特性來完成的效果,并沒有添加其他什么邏輯。

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • 基于Android FileProvider 屬性配置詳解及FileProvider多節(jié)點(diǎn)問題

    基于Android FileProvider 屬性配置詳解及FileProvider多節(jié)點(diǎn)問題

    這篇文章主要介紹了基于Android FileProvider 屬性配置詳解及FileProvider多節(jié)點(diǎn)問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2020-03-03
  • Android使用GridView實(shí)現(xiàn)日歷的方法

    Android使用GridView實(shí)現(xiàn)日歷的方法

    本篇文章主要介紹了Android使用GridView實(shí)現(xiàn)日歷的方法,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-08-08
  • Android10?客戶端事務(wù)管理ClientLifecycleManager源碼解析

    Android10?客戶端事務(wù)管理ClientLifecycleManager源碼解析

    這篇文章主要介紹了Android10?客戶端事務(wù)管理ClientLifecycleManager源碼解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-10-10
  • Android Bitmap的加載優(yōu)化與Cache相關(guān)介紹

    Android Bitmap的加載優(yōu)化與Cache相關(guān)介紹

    這篇文章主要介紹了Android中性能優(yōu)化之Bitmap的加載優(yōu)化與Cache相關(guān)內(nèi)容介紹,文中介紹的很詳細(xì),對(duì)大家具有一定的參考價(jià)值,需要的朋友們下面來一起看看吧。
    2017-02-02
  • 解決android Listview的item中最外層Margin失效的問題

    解決android Listview的item中最外層Margin失效的問題

    下面小編就為大家?guī)硪黄鉀Qandroid Listview的item中最外層Margin失效的問題。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-04-04
  • Android實(shí)現(xiàn)微信自動(dòng)搶紅包的程序

    Android實(shí)現(xiàn)微信自動(dòng)搶紅包的程序

    簡(jiǎn)單實(shí)現(xiàn)了微信自動(dòng)搶紅包的服務(wù),原理就是根據(jù)關(guān)鍵字找到相應(yīng)的View, 然后自動(dòng)點(diǎn)擊,接下來通過本文給大家介紹Android實(shí)現(xiàn)微信自動(dòng)搶紅包的程序,對(duì)android微信自動(dòng)搶紅包相關(guān)知識(shí)感興趣的朋友一起學(xué)習(xí)吧
    2016-02-02
  • 快速了解Android Room使用細(xì)則

    快速了解Android Room使用細(xì)則

    這篇文章主要為大家介紹了快速了解Android Room使用細(xì)則,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-03-03
  • Android音頻焦點(diǎn)管理實(shí)例詳解

    Android音頻焦點(diǎn)管理實(shí)例詳解

    音頻是個(gè)專業(yè)術(shù)語(yǔ),音頻一詞已用作一般性描述音頻范圍內(nèi)和聲音有關(guān)的設(shè)備及其作用,人類能夠聽到的所有聲音都稱之為音頻,它可能包括噪音等,下面這篇文章主要給大家介紹了關(guān)于Android音頻焦點(diǎn)管理的相關(guān)資料,需要的朋友可以參考下
    2022-01-01
  • Flutter啟動(dòng)頁(yè)(閃屏頁(yè))的具體實(shí)現(xiàn)及原理詳析

    Flutter啟動(dòng)頁(yè)(閃屏頁(yè))的具體實(shí)現(xiàn)及原理詳析

    這篇文章主要給大家介紹了關(guān)于Flutter啟動(dòng)頁(yè)(閃屏頁(yè))的具體實(shí)現(xiàn)及原理的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用Flutter具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-04-04
  • Kotlin中的一些技巧與迂回操作分享

    Kotlin中的一些技巧與迂回操作分享

    這篇文章主要給大家介紹了關(guān)于Kotlin中的一些技巧與迂回操作的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用kotlin具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2018-07-07

最新評(píng)論