Android 浮动操作按钮不';在“代码”视图中设置设计后,不会在“设计”视图中显示
新年快乐。我在代码视图中设置了一个floatingActionButton,但它没有在设计视图中显示该按钮。这里出现了什么问题?如何解决Android 浮动操作按钮不';在“代码”视图中设置设计后,不会在“设计”视图中显示,android,android-support-library,floating-action-button,Android,Android Support Library,Floating Action Button,新年快乐。我在代码视图中设置了一个floatingActionButton,但它没有在设计视图中显示该按钮。这里出现了什么问题?如何解决 dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.android.support:design:23.1.1' } <?x
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="match_parent"
tools:context=".MainActivity">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:clickable="true"
app:layout_anchor="@id/viewOne"
app:layout_anchorGravity="bottom|right|end"
app:rippleColor="#FFFFff" />
</android.support.design.widget.CoordinatorLayout>
</RelativeLayout>
依赖项{
编译文件树(目录:“libs”,包括:['*.jar'])
编译'com.android.support:appcompat-v7:23.1.1'
编译'com.android.support:design:23.1.1'
}
只要写下这段代码..这会很有效的
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/fabCreateGroup"
app:fabSize="normal"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_margin="15dp"
android:scaleType="center"
android:src="@drawable/youricon"
app:backgroundTint="@color/colorPrimary" />
当我用线性布局替换cordinatorLayout时,它显示在设计视图中,但可以运行应用程序。似乎这段代码只有在协调器布局下才有效。还有其他答案吗?没有问题,您可以尝试通过删除app:layout_-anchor=“@id/viewOne”
来解决问题,如果您说您的代码有问题,您需要添加该代码!!!!!当我用线性布局替换cordinatorLayout时,它显示在设计视图中,但可以运行应用程序。似乎这段代码只有在协调器布局下才有效。还有其他答案吗?