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

Android中FloatingActionButton實現(xiàn)懸浮按鈕實例

 更新時間:2017年04月25日 09:26:44   作者:ROOM先生  
這篇文章主要介紹了Android中FloatingActionButton實現(xiàn)懸浮按鈕實例,具有一定的參考價值,感興趣的小伙伴們可以參考一下。

Android中FloatingActionButton(懸浮按鈕) 使用不是特別多,常規(guī)性APP應(yīng)用中很少使用該控件. 當然他的使用方法其實很簡單.直接上代碼:

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"
  android:layout_width="match_parent"
  android:layout_height="match_parent">

  <CheckBox
    android:id="@+id/cbDelay"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="10dp"
    android:layout_marginTop="10dp"
    android:text="delay" />

  <RelativeLayout
    android:id="@+id/rlAddBill"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentStart="true"
    android:layout_below="@+id/fab01Add"
    android:layout_marginLeft="10dp"
    android:background="#00000000"
    android:visibility="gone">

    <LinearLayout
      android:id="@+id/ll01"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentStart="true"
      android:layout_below="@+id/ll02"
      android:orientation="horizontal">

      <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:layout_toLeftOf="@+id/miniFab01"
        android:layout_weight="1"
        android:gravity="right"
        android:paddingBottom="5dp"
        android:text="銷售單"
        android:textColor="@android:color/white"
        android:textSize="15sp"
        android:visibility="gone" />

      <android.support.design.widget.FloatingActionButton
        android:id="@+id/miniFab01"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="25dp"
        android:src="@mipmap/btn_play_normal"
        app:backgroundTint="@color/colorAccent"
        app:elevation="5dp"
        app:fabSize="mini" />
    </LinearLayout>

    <LinearLayout
      android:id="@+id/ll02"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentStart="true"
      android:layout_below="@+id/ll03"
      android:orientation="horizontal">

      <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:layout_toLeftOf="@+id/miniFab02"
        android:layout_weight="1"
        android:gravity="right"
        android:paddingBottom="5dp"
        android:text="銷售退貨"
        android:textColor="@android:color/white"
        android:textSize="15sp"
        android:visibility="gone" />

      <android.support.design.widget.FloatingActionButton
        android:id="@+id/miniFab02"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="25dp"
        android:src="@mipmap/btn_play_normal"
        app:backgroundTint="@color/colorAccent"
        app:elevation="5dp"
        app:fabSize="mini" />
    </LinearLayout>

    <LinearLayout
      android:id="@+id/ll03"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentStart="true"
      android:layout_alignParentTop="true"
      android:orientation="horizontal">

      <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:layout_toLeftOf="@+id/miniFab02"
        android:layout_weight="1"
        android:gravity="right"
        android:paddingBottom="5dp"
        android:text="收款單"
        android:textColor="@android:color/white"
        android:textSize="15sp"
        android:visibility="gone" />

      <android.support.design.widget.FloatingActionButton
        android:id="@+id/miniFab03"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="25dp"
        android:src="@mipmap/btn_play_normal"
        app:backgroundTint="@color/colorAccent"
        app:elevation="5dp"
        app:fabSize="mini" />
    </LinearLayout>
  </RelativeLayout>

  <android.support.design.widget.FloatingActionButton
    android:id="@+id/fab01Add"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentStart="true"
    android:layout_below="@+id/cbDelay"
    android:layout_marginRight="15dp"
    android:layout_marginTop="22dp"
    android:src="@mipmap/btn_play_normal"
    app:backgroundTint="#31bfcf"
    app:elevation="5dp"
    app:fabSize="normal"
    app:rippleColor="#e7d161" />
</RelativeLayout>

MainActivity:

package com.example.liupanpan.floatingactionbuttondemo;

import android.animation.AnimatorInflater;
import android.animation.AnimatorSet;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {
  private CheckBox cbDelay;
  private FloatingActionButton fab01Add;
  private boolean isAdd = false;
  private RelativeLayout rlAddBill;
  private int[] llId = new int[]{R.id.ll01, R.id.ll02, R.id.ll03};
  private LinearLayout[] ll = new LinearLayout[llId.length];
  private int[] fabId = new int[]{R.id.miniFab01, R.id.miniFab02, R.id.miniFab03};
  private FloatingActionButton[] fab = new FloatingActionButton[fabId.length];
  private AnimatorSet addBillTranslate1;
  private AnimatorSet addBillTranslate2;
  private AnimatorSet addBillTranslate3;
  private AnimatorSet addBillTranslate4;
  private AnimatorSet addBillTranslate5;
  private AnimatorSet addBillTranslate6;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.basic_fab_activity);
    initView();
    setDefaultValues();
    bindEvents();
  }

  private void initView() {
    cbDelay = (CheckBox) findViewById(R.id.cbDelay);
    fab01Add = (FloatingActionButton) findViewById(R.id.fab01Add);
    rlAddBill = (RelativeLayout) findViewById(R.id.rlAddBill);
    for (int i = 0; i < llId.length; i++) {
      ll[i] = (LinearLayout) findViewById(llId[i]);
    }
    for (int i = 0; i < fabId.length; i++) {
      fab[i] = (FloatingActionButton) findViewById(fabId[i]);
    }
  }

  private void setDefaultValues() {
    addBillTranslate1 = (AnimatorSet) AnimatorInflater.loadAnimator(this, R.animator.add_bill_anim);
    addBillTranslate2 = (AnimatorSet) AnimatorInflater.loadAnimator(this, R.animator.add_bill_anim);
    addBillTranslate3 = (AnimatorSet) AnimatorInflater.loadAnimator(this, R.animator.add_bill_anim);
//    addBillTranslate4 = (AnimatorSet) AnimatorInflater.loadAnimator(this, R.animator.add_bill_anim);
//    addBillTranslate5 = (AnimatorSet) AnimatorInflater.loadAnimator(this, R.animator.add_bill_anim);
//    addBillTranslate6 = (AnimatorSet) AnimatorInflater.loadAnimator(this, R.animator.add_bill_anim);
  }

  private void bindEvents() {
    fab01Add.setOnClickListener(this);
    for (int i = 0; i < fabId.length; i++) {
      fab[i].setOnClickListener(this);
    }
  }

  @Override
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.fab01Add:
        fab01Add.setImageResource(isAdd ? R.mipmap.ic_launcher_round : R.mipmap.ic_launcher_round);
        isAdd = !isAdd;
        rlAddBill.setVisibility(isAdd ? View.VISIBLE : View.GONE);
        if (isAdd) {
          addBillTranslate1.setTarget(ll[0]);
          addBillTranslate1.start();
          addBillTranslate2.setTarget(ll[1]);
          addBillTranslate2.setStartDelay(cbDelay.isChecked() ? 50 : 0);
          addBillTranslate2.start();
          addBillTranslate3.setTarget(ll[2]);
          addBillTranslate3.setStartDelay(cbDelay.isChecked() ? 100 : 0);
          addBillTranslate3.start();
//          addBillTranslate4.setTarget(ll[3]);
//          addBillTranslate4.setStartDelay(cbDelay.isChecked() ? 250 : 0);
//          addBillTranslate4.start();
//          addBillTranslate5.setTarget(ll[4]);
//          addBillTranslate5.setStartDelay(cbDelay.isChecked() ? 300 : 0);
//          addBillTranslate5.start();
//          addBillTranslate6.setTarget(ll[5]);
//          addBillTranslate6.setStartDelay(cbDelay.isChecked() ? 350 : 0);
//          addBillTranslate6.start();
        }
        break;
      case R.id.miniFab01:
        hideFABMenu();
        break;
      case R.id.miniFab02:

        hideFABMenu();
        break;
      case R.id.miniFab03:
        hideFABMenu();
        break;
      default:
        break;

    }
  }

  private void hideFABMenu() {
    rlAddBill.setVisibility(View.GONE);
    fab01Add.setImageResource(R.mipmap.ic_launcher_round);
    isAdd = false;
  }
}

運行程序,就可以實現(xiàn)當前的效果.問題XML的圖片請自己替換一下,demo就不上傳了.

效果如下:

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

相關(guān)文章

  • Kotlin協(xié)程的線程調(diào)度示例詳解

    Kotlin協(xié)程的線程調(diào)度示例詳解

    這篇文章主要為大家介紹了Kotlin協(xié)程的線程調(diào)度示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2022-12-12
  • 基于Android在布局中動態(tài)添加view的兩種方法(總結(jié))

    基于Android在布局中動態(tài)添加view的兩種方法(總結(jié))

    下面小編就為大家?guī)硪黄贏ndroid在布局中動態(tài)添加view的兩種方法(總結(jié))。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-10-10
  • android中webview定位問題示例詳解

    android中webview定位問題示例詳解

    這篇文章主要給大家介紹了關(guān)于android中webview定位問題的相關(guān)資料,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧。
    2017-12-12
  • Kotlin結(jié)合Rxjava+Retrofit實現(xiàn)極簡網(wǎng)絡(luò)請求的方法

    Kotlin結(jié)合Rxjava+Retrofit實現(xiàn)極簡網(wǎng)絡(luò)請求的方法

    這篇文章主要給大家介紹了關(guān)于Kotlin結(jié)合Rxjava+Retrofit實現(xiàn)極簡網(wǎng)絡(luò)請求的相關(guān)內(nèi)容,文中分別對Rxjava和Retrofit進行了簡單的介紹,然后通過示例代碼詳細介紹了如何實現(xiàn)極簡網(wǎng)絡(luò)請求,需要的朋友可以參考借鑒,下面來一起看看吧。
    2017-11-11
  • Android實現(xiàn)滑動加載數(shù)據(jù)的方法

    Android實現(xiàn)滑動加載數(shù)據(jù)的方法

    這篇文章主要介紹了Android實現(xiàn)滑動加載數(shù)據(jù)的方法,實例分析了Android通過滑動實現(xiàn)動態(tài)加載數(shù)據(jù)的技巧,具有一定參考借鑒價值,需要的朋友可以參考下
    2015-07-07
  • Android Fragment使用全解

    Android Fragment使用全解

    這篇文章主要介紹了Android Fragment使用的相關(guān)資料,幫助大家更好的理解和學習使用Android開發(fā),感興趣的朋友可以了解下
    2021-04-04
  • Android編程獲取網(wǎng)絡(luò)時間實例分析

    Android編程獲取網(wǎng)絡(luò)時間實例分析

    這篇文章主要介紹了Android編程獲取網(wǎng)絡(luò)時間,結(jié)合實例形式對比分析了Android通過訪問網(wǎng)絡(luò)及通過GPS獲取網(wǎng)絡(luò)時間的具體步驟與實現(xiàn)技巧,需要的朋友可以參考下
    2016-01-01
  • Android 測量文字寬度的實例方法

    Android 測量文字寬度的實例方法

    在本篇文章里小編給大家整理了關(guān)于Android 測量文字寬度的實例方法,需要的朋友們可以參考學習下。
    2020-02-02
  • Android開發(fā)解決popupWindow重疊報錯問題

    Android開發(fā)解決popupWindow重疊報錯問題

    今天小編就為大家分享一篇關(guān)于Android開發(fā)解決popupWindow重疊報錯問題的文章,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧
    2018-10-10
  • Android高級組件AutoCompleteTextView自動完成文本框使用詳解

    Android高級組件AutoCompleteTextView自動完成文本框使用詳解

    這篇文章主要介紹了Android高級組件AutoCompleteTextView自動完成文本框的使用,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-12-12

最新評論

钟祥市| 合肥市| 博爱县| 调兵山市| 扬州市| 惠水县| 浦东新区| 天全县| 屏山县| 永丰县| 宁远县| 西和县| 赣州市| 宁安市| 乐平市| 汤阴县| 高要市| 田林县| 三河市| 乌鲁木齐县| 伊川县| 昭觉县| 宜川县| 岫岩| 西城区| 萍乡市| 洞头县| 芮城县| 武定县| 嘉兴市| 峨山| 兰溪市| 绥芬河市| 山西省| 五指山市| 蓬溪县| 茌平县| 长白| 涞源县| 乌兰县| 扎兰屯市|