日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Android >内容正文

Android

Android Design Support Library初探-更新中

發布時間:2025/3/21 Android 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Android Design Support Library初探-更新中 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

導讀

這個兼容庫容易和Google之前發布的 Android Support Library 22.1 混淆,兩者的區別在于:

  • Android Support Library 22.1 只是支持了一些基本空間的材料設計化,
  • Android Design Support Library 更多的是對一些特效的實現,這個庫和github上的很多開源的項目有很大的關系,material design的很多效果,同一種效果在github上有太多的實現,現在官方將其標準化了。
  • -

原文地址

如果你的英文666666,那就來這里看吧~
Android Design Support Library

重要控件

Android 5.0是有史以來最重要的Android版本之一,這其中大部分歸功于material design的引入,這種新的設計語言讓整個Android的用戶體驗煥然一新。 官方的詳細專題有更詳細的說明來介紹使用material design帶來的好處。但我們也知道,這種設計對于開發者來講,尤其是在意向后兼容的開發者來說是一種挑戰。

在Android Design Support Library的幫助下,我們為所有的開發者,所有的2.1以上的設備,帶來了一些重要的material design控件。
比如:
navigation drawer view, floating labels for editing text, a floating action button, snackbar, tabs, and a motion and scroll framework to tie them together.

  • navigation drawer view,
  • floating labels for editing text(輸入控件的懸浮標簽)
  • floating action button (懸浮操作按鈕)
  • snackbar
  • tabs(選項卡)
  • a motion and scroll framework to tie them together(將這些控件結合在一起的手勢滾動框架)

官方視頻簡介

抽屜導航是app識別度與內部導航的關鍵,保持這里設計上的一致對app的可用性至關重要,尤其是對第一次使用的用戶。NavigationView 通過提供抽屜導航所需要的框架讓實現更簡單,同時它還能夠直接通過菜單資源文件來直接生成導航元素。

把NavigationView 作為DrawerLayout的內容視圖來使用,比如下面的布局:

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"android:layout_width="match_parent"android:layout_height="match_parent"android:fitsSystemWindows="true"><!-- your content layout --><android.support.design.widget.NavigationView android:layout_width="wrap_content"android:layout_height="match_parent"android:layout_gravity="start"app:headerLayout="@layout/drawer_header"app:menu="@menu/drawer"/> </android.support.v4.widget.DrawerLayout>

你會注意到NavigationView的兩個屬性:

  • app:headerLayout :控制頭部的布局(可選)
  • app:menu:導航菜單的資源文件(必選),也可以在運行時配置。

NavigationView處理好了和狀態欄的關系,可以確保NavigationView在API21(5.0)設備上正確的和狀態欄交互。

最簡單的抽屜菜單就是幾個可點擊的菜單集合:

<group android:checkableBehavior="single"><item android:id="@+id/navigation_item_1"android:checked="true"android:icon="@drawable/ic_android"android:title="@string/navigation_item_1"/><item android:id="@+id/navigation_item_2"android:icon="@drawable/ic_android"android:title="@string/navigation_item_2"/> </group>

被點擊過的item會高亮顯示在抽屜菜單中,讓用戶知道哪個菜單被選中。

你也可以在menu中使用subheader來為菜單分組:

<itemandroid:id="@+id/navigation_subheader"android:title="@string/navigation_subheader"><menu><itemandroid:id="@+id/navigation_sub_item_1"android:icon="@drawable/ic_android"android:title="@string/navigation_sub_item_1"/><itemandroid:id="@+id/navigation_sub_item_2"android:icon="@drawable/ic_android"android:title="@string/navigation_sub_item_2"/></menu> </item>

你可以設置一個OnNavigationItemSelectedListener,使用起setNavigationItemSelectedListener()來獲取元素被選中的回調時間,它為你提供被點擊的 菜單元素 ,讓你可以處理選擇事件,改變復選框狀態,加載新內容,關閉導航菜單,以及其他任何你想做的操作。

效果和Code請移步 NavigationDrawer和NavigationView-Android M新控件


輸入框控件的懸浮標簽

在material design中,即使是簡單的EditText,也有提升的余地。 通常EditText會在用戶輸入第一個字母后隱藏提示信息,但是現在可以使用TextInputLayout來將EditText封裝起來,提示信息(hint)會變成一個顯示在EditText之上的floating label,這樣用戶就始終知道他們現在輸入的是什么了。

TextInputLayout:

Layout which wraps an EditText (or descendant) to show a floating label when the hint is hidden due to the user inputting text. Also supports showing an error via setErrorEnabled(boolean) and setError(CharSequence).

效果圖

Code

第一步 加入依賴

本工程的build.gradle中

compile 'com.android.support:design:23.1.1'

懸浮操作按鈕 Floating Action Button

Snackbar

選項卡

CoordinatorLayout, 手勢, 以及滾動

CoordinatorLayout與懸浮操作按鈕

CoordinatorLayout與app bar

可伸縮折疊的Toolbar (Collapsing Toolbar)

CoordinatorLayout與自定義view


參考文檔

官方博客

官方文檔

官方Demo

總結

以上是生活随笔為你收集整理的Android Design Support Library初探-更新中的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。