相关疑难解决方法(0)

以编程方式更改可绘制颜色

我正在尝试通过代码更改白色标记图像上的颜色.我已经读过下面的代码应该改变颜色,但我的标记仍然是白色的.

Drawable.setColorFilter( 0xffff0000, Mode.MULTIPLY )
Run Code Online (Sandbox Code Playgroud)

我错过了什么?有没有其他方法可以改变位于我的res文件夹中的drawables上的颜色?

android

119
推荐指数
11
解决办法
16万
查看次数

Android Studio 应用程序在真实设备上崩溃,但在模拟器上运行

几周前我开始使用 Android Studio。我开发了一个具有正常登录屏幕的应用程序,并且在模拟器上一切正常。但如果我尝试在 Samsung Galaxy S7 Edge (Android 7.0) 上运行该应用程序,该应用程序会立即崩溃。

我已经模拟了具有 API 23 的 Nexus 5,当我尝试使用具有 API 24 的模拟 Pixel 时,模拟器也会崩溃。所以我猜这个问题取决于Android版本?

Logcat(我优化了我正在使用的所有图像,现在这是我的新 Logcat):

03-30 15:53:13.841 31645-31645/de.mm.uchron E/AndroidRuntime: FATAL EXCEPTION: main
                                                                      Process: de.mm.uchron, PID: 31645
                                                                      java.lang.OutOfMemoryError: Failed to allocate a 3686412 byte allocation with 2474312 free bytes and 2MB until OOM
                                                                          at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
                                                                          at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
                                                                          at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:700)
                                                                          at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:535)
                                                                          at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:1179)
                                                                          at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:770)
                                                                          at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:621)
                                                                          at android.content.res.Resources.loadDrawable(Resources.java:1727)
                                                                          at android.content.res.TypedArray.getDrawable(TypedArray.java:945)
                                                                          at android.widget.ImageView.<init>(ImageView.java:157)
                                                                          at android.widget.ImageButton.<init>(ImageButton.java:85)
                                                                          at android.widget.ImageButton.<init>(ImageButton.java:81)
                                                                          at android.support.v7.widget.AppCompatImageButton.<init>(AppCompatImageButton.java:60)
                                                                          at …
Run Code Online (Sandbox Code Playgroud)

java debugging android android-studio

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

android ×2

android-studio ×1

debugging ×1

java ×1