浮动动作按钮显示为正方形 [英] Floating Action Button appearing as a square

查看:85
本文介绍了浮动动作按钮显示为正方形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用Android应用,正在使用最新添加的浮动操作按钮".但是,在编译了必要的库并将fab添加到我的xml文件之后,就像其他地方一样,它看起来像一个正方形,而我希望它是一个圆形.

I am currently working on an Android app and using the latest addition of the Floating Action Button. However, after compiling the necessary libraries and adding the fab into my xml file, it appears as a square while I am expecting it to be a circle, just like everywhere else.

我使用与网上找到的相同的基本代码来实现fab,我的结果是一个正方形,而他们的结果是一个不错的圆形fab.

I use the same basic code to implement the fab as found online and my result is a square and theirs is a nice circle fab.

这是我的代码:

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="end|bottom"
    android:layout_margin="16dp"
    android:src="@drawable/ic_person_add_black_24dp" />

以下是显示的屏幕截图:

Here is an screenshot of what is displayed:

如何将晶圆厂(在此处添加联系人)显示为圆形?

How to display the fab (add contact here) as a circle?

谢谢

推荐答案

我不知道这是不是解决了这个问题的方法,但是我停止了为另一个项目工作的时间&我的其他项目都没有这个问题.

I don't know if this is what solved it but I stopped working on this project for another one for a little bit & I didn't have this problem on my other project.

如果您的活动扩展了Activity而不是AppCompatActivity,则AndroidStudio似乎会创建一个方形fab.

AndroidStudio seems to create a square fab if your activity extends Activity and not AppCompatActivity.

这篇关于浮动动作按钮显示为正方形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆