2017-08-15 66 views
0

今天,我做了一个使用FAB作为登录按钮的登录活动。代码是正确的。当我安排布局文件时,我使用了以下代码:FAB layout_anchor与现有资源崩溃

android:id="@+id/floatingActionButton3" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:layout_gravity="center_horizontal" 
android:layout_marginTop="20dp" 
android:clickable="true" 
app:elevation="15dp" 
app:layout_anchor="@id/EText1" 
app:layout_anchorGravity="end" 
app:fabSize="normal" 
app:srcCompat="@drawable/ic_arrow_forward" 

当我输入这些代码时,Android Studio没有报告任何错误。但是,当我要运行它作为我的手机上调试应用程序,它坠毁与此错误:

Error:(16, 28) No resource found that matches the given name (at 'layout_anchor' with value '@id/EText1'). 

而且我注意到一个错误的渲染错误:

Couldn't resolve resource @id/visible 

我希望有人能够帮助我解决这个问题。如果有人能给我一个解决方案,我将不胜感激。不管怎么说,还是要谢谢你!

+1

请发布您的整个XML布局。 – Bob

回答

0

确保你有一个“EText1”id的视图,并确保你的xml文件中的EText1高于你的FAB。把整个XML文件放在一起比较好。

+0

谢谢!我解决了这个问题。非常感谢! –