代码之家  ›  专栏  ›  技术社区  ›  Virendra Varma

andoidx库中的浮动操作按钮

  •  4
  • Virendra Varma  · 技术社区  · 6 年前

    嗨,有人知道如何使用androidx库的浮动操作按钮吗?我想在androidx库中,他们会取代androidx库吗

    implementation 'com.android.support:appcompat-v7:xx.xx.xx'
    

    implementation 'androidx.appcompat:appcompat:1.0.0'
    

    1 回复  |  直到 6 年前
        1
  •  41
  •   AskNilesh    5 年前

    dependencies

    implementation 'com.google.android.material:material:1.0.0-rc01'
    

    更多信息请查看 Migrating to AndroidX

    <com.google.android.material.floatingactionbutton.FloatingActionButton
            android:id="@+id/imgFour"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_close"
            app:backgroundTint="@color/colorAccent"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:tint="@android:color/white" />
    

    笔记

    app:tint="@android:color/white" 用于更改的图标颜色 FloatingActionButton

    app:backgroundTint="@color/colorAccent" background 颜色 浮动操作按钮

    使用 我们需要导入的内部活动或片段 浮动操作按钮 这样地

    import com.google.android.material.floatingactionbutton.FloatingActionButton
    
        2
  •  9
  •   Maverick Meerkat    5 年前

    <com.google.android.material.floatingactionbutton.FloatingActionButton ... />
    

    同时在gradle文件中添加:

    implementation 'com.google.android.material:material:1.0.0'
    
        3
  •  -1
  •   Abra BlueJK    5 年前

    要在androidx库中使用浮动操作按钮,请使用以下实现

    implementation 'com.google.android.material:material:1.0.0'