最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

android頂部(toolbar)搜索框實現(xiàn)代碼

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

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

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="標題欄"
      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="請輸入搜索內(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的特性來完成的效果,并沒有添加其他什么邏輯。

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關文章

  • Android ProgressBar進度條使用詳解

    Android ProgressBar進度條使用詳解

    ProgressBar進度條,分為旋轉進度條和水平進度條,進度條的樣式根據(jù)需要自定義,這篇文章主要介紹了Android ProgressBar進度條使用方法,感興趣的小伙伴們可以參考一下
    2016-02-02
  • Flutter中灰屏問題的原因及解決方法

    Flutter中灰屏問題的原因及解決方法

    生產(chǎn)中的 flutter 應用程序中的灰屏是一種通用占位符,當框架遇到問題無法渲染預期用戶界面時就會顯示,所以基本上是出現(xiàn)問題時的后備指示器,本文給大家介紹了Flutter中灰屏問題的原因及解決方法,需要的朋友可以參考下
    2024-06-06
  • Android實現(xiàn)獲取應用程序相關信息列表的方法

    Android實現(xiàn)獲取應用程序相關信息列表的方法

    這篇文章主要介紹了Android實現(xiàn)獲取應用程序相關信息列表的方法,是應用管理器常用的功能,需要的朋友可以參考下
    2014-07-07
  • Android原生嵌入React Native詳解

    Android原生嵌入React Native詳解

    這篇文章主要為大家詳細介紹了Android原生嵌入React Native的相關資料,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2016-09-09
  • Android 如何實現(xiàn)亮度自動調節(jié)

    Android 如何實現(xiàn)亮度自動調節(jié)

    這篇文章主要介紹了Android 如何實現(xiàn)亮度自動調節(jié),幫助大家更好的理解和學習使用Android開發(fā),感興趣的朋友可以了解下
    2021-04-04
  • Android動態(tài)表格的實現(xiàn)代碼(內(nèi)容、樣式可擴縮)

    Android動態(tài)表格的實現(xiàn)代碼(內(nèi)容、樣式可擴縮)

    這篇文章主要介紹了Android動態(tài)表格的實現(xiàn)代碼(內(nèi)容、樣式可擴縮),本文通過實例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2021-09-09
  • Android實現(xiàn)3D翻轉動畫效果

    Android實現(xiàn)3D翻轉動畫效果

    這篇文章主要為大家詳細介紹了Android實現(xiàn)3D翻轉動畫效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-12-12
  • Android 判斷SIM卡屬于哪個移動運營商的實現(xiàn)代碼

    Android 判斷SIM卡屬于哪個移動運營商的實現(xiàn)代碼

    有時候我們需要在Android中獲取本機網(wǎng)絡提供商呢,這里簡單分享下,方便需要的朋友
    2013-05-05
  • Android動畫系列之屬性動畫的基本使用教程

    Android動畫系列之屬性動畫的基本使用教程

    這篇文章主要給大家介紹了關于Android動畫系列教程之屬性動畫的相關資料,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2020-12-12
  • Android Studio編寫微信頁面提交功能

    Android Studio編寫微信頁面提交功能

    這篇文章主要介紹了基于Android Studio編寫微信頁面提交功能,本文通過實例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2020-03-03

最新評論

扎囊县| 孝感市| 察哈| 获嘉县| 罗城| 紫金县| 和林格尔县| 江山市| 永州市| 阿拉善右旗| 邛崃市| 泰安市| 平泉县| 梁平县| 西昌市| 城固县| 新巴尔虎右旗| 和林格尔县| 金塔县| 缙云县| 舟山市| 五河县| 延吉市| 延津县| 龙南县| 瑞安市| 伊金霍洛旗| 肇州县| 新疆| 宜兴市| 大庆市| 凤山市| 体育| 五指山市| 永宁县| 巴青县| 北安市| 安陆市| 密云县| 温州市| 马龙县|