【问题标题】:How to add Floating Action button with appcompact如何使用 appcompat 添加浮动操作按钮
【发布时间】:2014-10-21 18:08:15
【问题描述】:

我最近通过 android sdk 更新到新的 android 5.0
并尝试使用 appcompact 添加浮动操作按钮 (FAB)。

我不想使用任何类型的外部库

如何使用 appcompact 按项目添加 FAB 按钮

【问题讨论】:

  • 你有什么问题?

标签: android android-xml floating-action-button


【解决方案1】:

制作 FAB 不需要任何特殊的库。创建一个扩展 ImageButton 的类,并在 onTouch 方法中上下缩放视图。

【讨论】:

    【解决方案2】:

    android 现在在他们的设计上有浮动操作按钮:

    只需在您的 gradle 文件中添加 compile 'com.android.support:design:22.2.0' 并添加

     <android.support.design.widget.FloatingActionButton
            android:id="@+id/fab"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="68dp"
            android:layout_marginRight="10dp"
            android:clickable="true"
            android:background="@mipmap/icon_plus_button"
            app:layout_anchor="@id/mainContent"
            app:layout_anchorGravity="bottom|right|end"
            app:fabSize="mini"
            app:backgroundTint="#5894EF"
            app:elevation="6dp"
            app:rippleColor="@android:color/transparent"
            app:pressedTranslationZ="12dp"/>
    

    在您的 xml 布局上。希望这对任何人都有帮助。

    【讨论】:

      猜你喜欢
      • 2015-09-09
      • 2015-01-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-06
      相关资源
      最近更新 更多