<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # 1. 前言 按照`Material Design`的理念,應用程序的界面不僅僅是一個平面,而應該是有立體效果的。在官方給出的示例中,最簡單且最具代表性的立面設計就是懸浮按鈕了。`FloatingActionButton`(簡稱,`FAB`)是`Material`庫中提供的一個控件,這個控件可以幫助我們比較輕松地實現懸浮按鈕的效果。它默認會使用`colorAccent`作為按鈕的顏色。 # 2. 使用 直接在`TestActivity`的布局文件中引入: ~~~ <?xml version="1.0" encoding="utf-8"?> <!--如果要使用FAB,那么就需要使用androidx.coordinatorlayout.widget.CoordinatorLayout包裹起來--> <androidx.coordinatorlayout.widget.CoordinatorLayout 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" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" android:orientation="vertical"> <!--引入下拉刷新控件--> <androidx.swiperefreshlayout.widget.SwipeRefreshLayout android:id="@+id/swiperefreshLayout" android:layout_width="match_parent" android:layout_height="match_parent" > <!-- 將內容包裹起來 --> <TextView android:layout_width="wrap_content" android:layout_height="?attr/actionBarSize" android:text="測試下拉刷新" /> </androidx.swiperefreshlayout.widget.SwipeRefreshLayout> <!--這里使用FAB懸浮按鈕--> <com.google.android.material.floatingactionbutton.FloatingActionButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_baseline_add_24" app:elevation="8dp" android:layout_gravity="bottom|end" android:layout_margin="16dp" /> </androidx.coordinatorlayout.widget.CoordinatorLayout> ~~~ 需要注意的是,如果不使用`CoordinatorLayout`包裹起來,`FAB`不會顯示。 效果: ![](https://img.kancloud.cn/49/4e/494e840928084f7351f11468e8d9e3e2_326x501.png) 至于如何進行事件處理,`FAB`和普通的`Button`其實沒什么兩樣,都是調用`setOnClickListener()`方法來設置按鈕的點擊事件,這里就不再演示。 # 3. 修改顏色 可以在`xml`中直接修改: ~~~ <!--FAB懸浮按鈕--> <com.google.android.material.floatingactionbutton.FloatingActionButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|end" android:layout_marginEnd="16dp" android:layout_marginBottom="76dp" android:src="@drawable/ic_baseline_add_24" app:backgroundTint="@color/white" app:elevation="8dp" /> ~~~ 使用`app:backgroundTint`屬性指定即可。 效果: ![](https://img.kancloud.cn/0d/1e/0d1ec104384706d4897faf7724ea8208_394x232.png)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看