- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
在了解了 Material Design 中的新方法后,我尝试在应用中实现一个 float 操作按钮。但是,我在预览(预览 Android 版本 21)中遇到此错误:
The following classes could not be instantiated:
- android.support.design.widget.FloatingActionButton
(First paragraph of error)
java.lang.NullPointerException
at android.support.v4.graphics.drawable.DrawableCompatLollipop.setTintList(DrawableCompatLollipop.java:56)
at android.support.v4.graphics.drawable.DrawableCompat$LollipopDrawableImpl.setTintList(DrawableCompat.java:145)
at android.support.v4.graphics.drawable.DrawableCompat.setTintList(DrawableCompat.java:270)
etc...
有人知道吗?这是我的 build.gradle:
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
classpath 'com.android.tools.build:gradle:1.2.3'
defaultConfig {
applicationId "owensetiawan.tutorials.fab"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:design:22.2.0'
}
如果有人能帮助我阐明我的问题,那就太好了。
最佳答案
嘿,我在实例化设计库时遇到了同样的问题,并通过这个解决了
第 1 步 > fab 代码
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:clickable="true"
android:src="@drawable/search"
app:backgroundTint="@color/color_fav"
app:borderWidth="0dp"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
/>
第二步>依赖
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:recyclerview-v7:22.2.1'
compile 'com.android.support:design:22.2.1'
compile "com.android.support:support-v4:22.2.1"
步骤3>解决上述问题的主要步骤
简单的:- 转到您的 xml 并单击预览,然后在预览栏中选择 AP1 21
关于android - FloatingActionButton 类无法实例化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31319127/
如果我正常运行应用程序,应用程序运行良好,但当我尝试测试它时显示错误,这里是错误的完整日志。 java.lang.RuntimeException: android.view.InflateExcep
只是想澄清一个概念上的疑问。 float 操作按钮的 hide() 函数类似于 visibility.GONE 还是 visibility.INVISIBLE? 最佳答案 简而言之:是的。 以下是从设
我在以下布局文件 activity_register 中有一个 float 操作按钮:
我在 CoordinatorLayout 中使用 FloatingActionButton,但与正常行为不同,我想在到达底部时显示它,以便让用户看到更多数据。 为此,我在 Internet 上找到了该
我在使用 FloatingActionButton 时遇到了一些问题,它在模拟器上可以正常工作,但是当我安装到我的手机(Galaxy s4,Android V4.4.4)时它无法正常工作我附上了一些图
我想在 Android 中创建一个类似于 Gmail 收件箱的简单布局。项目列表和用于添加新项目的 FloatingActionButton。在 Android Studio 的设计选项卡中,按钮显示
您好,我正在尝试实现 makovkastar 的 [FloatingActionButton][1] 库。 (因为它是向后兼容的。它适用于单个 FAB,但是当添加 2 个按钮时,“列表”似乎只附加到一
我无法制作正确的按钮。如果我们为 CoordinatorLayout 设置 android: layout_height = "90dp",那么一切都会发生,但我希望它没有硬值。我可以这样做吗?
我正在使用 this library这对于实现带有自定义菜单和许多其他内容的 float 操作按钮来说非常棒。 但是在使用这个库时,我遇到了更改 FloatingActionMenu 中的 Float
我需要创建一个带有白色边框并填充纯色(蓝色或灰色)的 FAB。 xml 我尝试了 How to change android design support library FAB Button bo
我越来越熟悉新的 support.design 库,但我正面临 FloatingActionButton 的这个问题。我试图以编程方式隐藏它,但按钮始终可见。 我觉得 app:layout_ancho
我在 api 21+ 中使用 FloatingActionButton 它显示完全正常,但如果我在 api 20 中查看它- 那么它在后台有四行。 下面是我的FloatingActionButton的
我正在使用 FloatingActionButton 和 OnClick。我想显示 PopupMenu 并使用漂亮的动画(旋转 90 度)旋转相同的 FAB 按钮。 点击时,它应该自己动画: 我能够在
最近我从GitHub下载了一段代码,并同步到我的android studio。这样做时我遇到了很多错误和问题,并以某种方式修复了其中的大部分。但是,我现在遇到的最后一个问题是我的 android st
我正在使用 Android 支持 FloatingActionButton (FAB) 和 CoordinatorLayout,我想将 FAB 锚定到 CardView。 这是我的代码:
我正在尝试在我的应用程序中使用 float 操作按钮 (FAB)。但是,当我声明相同时,我得到了错误: android.support.design.widget.FloatingActionButt
我目前正在开发一个使用 FloatingActionButton 的 Android 应用程序。我想使用快速拨号来执行多个操作,如 this 中所述,旋转/跳出操作按钮。 Google 在 Andro
我找不到获得无边框 FAB 的方法。例如,当我尝试时: 我得到: 请注意 FAB 周围的边界。我已经尝试过 adjustViewBounds="true"和 android:background="
目前正在开发一个应用程序,我需要在 折叠工具栏 的右下角添加“共享”和“添加”按钮(视差效果)。 它可能隐藏在滚动中或可能位于 Actionbar 上。添加了我想要实现的图像。目前不知道如何执行此操作
我正在尝试创建一个带有如下图标的 FloatingActionButton:https://github.com/jd-alexander/LikeButton 如您所见,该按钮是动画,而不仅仅是两个
我是一名优秀的程序员,十分优秀!