Android andoidx库中的浮动操作按钮
大家好,有人知道如何在androidx库中使用浮动操作按钮吗?我想,在androidx库中,他们会取代它Android andoidx库中的浮动操作按钮,android,floating-action-button,androidx,Android,Floating Action Button,Androidx,大家好,有人知道如何在androidx库中使用浮动操作按钮吗?我想,在androidx库中,他们会取代它 implementation 'com.android.support:appcompat-v7:xx.xx.xx' 借 但这对任何建议都没有帮助?在andoidx库中使用浮动操作按钮使用下面的依赖项 implementation 'com.google.android.material:material:1.0.0-rc01' 有关更多信息,请查看 完整示例 XML代码 要在andro
implementation 'com.android.support:appcompat-v7:xx.xx.xx'
借
但这对任何建议都没有帮助?在andoidx库中使用浮动操作按钮使用下面的
依赖项
implementation 'com.google.android.material:material:1.0.0-rc01'
有关更多信息,请查看
完整示例
XML代码
要在androidx库中使用浮动操作按钮,请使用此实现
implementation 'com.google.android.material:material:1.0.0'
现在,您可以迁移到Android x并将xml替换为:
<com.google.android.material.floatingactionbutton.FloatingActionButton ... />
导入com.google.android.material.floatingactionbutton.floatingactionbutton但如何让按钮显示在右下角,而不是左上角,就像这段代码一样?@RichardBarraclough没有理解你?我尝试了上面的代码,按钮出现了,但是它在屏幕的左上角。@RichardBarraclough您的按钮出现在屏幕的左上角,因为我已经添加了app:layout\u constraintBottom\u toBottomOf
app:layout\u constraintentend\u toEndOf
,app:layout\u constraints start\u toStartOf
,app:layout\u constraintop\u topof
只需从代码中删除此项,并根据需要应用约束即可
import com.google.android.material.floatingactionbutton.FloatingActionButton
implementation 'com.google.android.material:material:1.0.0'
<com.google.android.material.floatingactionbutton.FloatingActionButton ... />
implementation 'com.google.android.material:material:1.0.0'