我在应用程序中使用“浮动操作按钮”时遇到了一些麻烦。在Android Studio模拟器中,无论是在应用程序模拟器中的xml文件的“设计”视图中,还是在实际设备中,当我运行该应用程序时,它都没有圆形,但是它是椭圆形的。此外,此错误仅在某些执行时发生...昨天,FAB在我的设备上也是循环的,但今天没有(我没有修改xml部分,而在Java方面,我没有处理它的方面)...
这是我在.xml文件中定义按钮的位置:
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/coor"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="1">
<RelativeLayout
android:id="@+id/relative"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/activity_horizontal_margin"
android:layout_weight="0.88">
<!-- Other elements-->
<!-- Parent element-->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/etEntrate"
android:textSize="@dimen/subtitles"
android:padding="@dimen/activity_horizontal_margin"
android:layout_alignRight="@+id/data"
android:layout_alignEnd="@+id/data"
android:layout_below="@+id/etSpese"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:layout_marginTop="@dimen/activity_horizontal_margin"
android:layout_marginBottom="@dimen/activity_horizontal_margin"/>
<!--FAB-->
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
app:srcCompat="@drawable/plus"
android:layout_alignTop="@+id/etEntrate"
android:layout_marginTop="59dp"
android:layout_alignLeft="@+id/etEntrate"
android:layout_alignStart="@+id/etEntrate"
android:layout_alignRight="@+id/etEntrate"
android:layout_alignEnd="@+id/etEntrate" />
<!--other elements-->
</RelativeLayout>
</LinearLayout>
这里有两张关于我如何在设备上看到FAB以及在模拟器上的外观的图片:
我设备上的FAB:
FAB在Android Studio的设计视图上
有人对此有想法吗?谢谢!
当然,FAB的宽度和高度设置为,wrap_content
但是您试图同时向左和向右对齐,这就是为什么它会拉伸的原因。只需删除其中之一即可。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句