小编hat*_*ata的帖子

添加ImageLoader时,getInstance(this)中的Android Volley错误

我在Android开发人员上使用Volley跟踪图像兑现教程,我遇到了请求图像请求并缓存它的问题,我想因为我创建的singelton(从教程中复制).

我的Eclipse给出了错误,getInstance(this)因为这是上下文,我想要一个图像.

ImageRequest request = new ImageRequest(
    url,
    new Response.Listener<Bitmap>() {
        @Override
        public void onResponse(Bitmap bitmap) {
            mNetworkImageView = (NetworkImageView) findViewById(R.id.ImageView);
            mImageLoader = MySingleton.getInstance(this).getImageLoader();
            mNetworkImageView.setImageUrl(IMAGE_URL, mImageLoader);
        //  mImageLoader = MySingleton.getInstance(this).getImageLoader();
        //  mImageLoader.get(IMAGE_URL, ImageLoader.getImageListener(mImageView,
        //      R.drawable.ic_launcher, R.drawable.ic_launcher));
            }
        },
    0,
    0,
    null,
    new Response.ErrorListener() {
        public void onErrorResponse(VolleyError error) {
        //  mImageView.setImageResource(R.drawable.ic_launcher);
        }
    });
MySingleton.getInstance(this).addToRequestQueue(request);
Run Code Online (Sandbox Code Playgroud)

这是单身人士:

package com.example.p;

import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.ImageLoader;
import com.android.volley.toolbox.Volley;

import android.content.Context;
import android.graphics.Bitmap;
import android.support.v4.util.LruCache;

public class MySingleton …
Run Code Online (Sandbox Code Playgroud)

singleton android android-volley

8
推荐指数
1
解决办法
7033
查看次数

如何防止BottomAppBar重叠内容

我想使用 CoordinatorLayout 在屏幕底部包含一个 BottomAppBar,并在剩余空间中显示一些内容(例如使用 ConstraintLayout)。

如果我向 CoordinatorLayout 添加一个 ConstraintLayout,然后我添加一个放置在 ConstraintLayout 底部的按钮,则该按钮被 BottomAppBar 覆盖。

我希望 ConstraintLayout 用完所有垂直空间,除了 BottomAppBar 所在的位置,这样按钮就不会被覆盖。

我尝试在 ConstraintLayout 中包含 app:layout_behavior="@string/appbar_scrolling_view_behavior",正如某些网站所建议的那样,但它不起作用。另外,在BottomAppBar 中设置app:layout_insetEdge="bottom",然后在ConstraintLayout 中设置app:layout_dodgeInsetEdges="bottom" 也不能正常工作,因为ConstraintLayout 然后在屏幕顶部溢出(但底部没有被覆盖)不再)。

下面是 xml 布局文件,其中BottomAppBar 覆盖了按钮。谢谢

    <?xml version="1.0" encoding="utf-8"?>

    <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/coordinatorLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MainActivity">

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="top"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

    <Button
        android:id="@+id/myButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent" />

    </androidx.constraintlayout.widget.ConstraintLayout>

    <com.google.android.material.bottomappbar.BottomAppBar
        android:id="@+id/bottomAppBar"
        style="@style/Widget.MaterialComponents.BottomAppBar.Colored"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom" />    
    </androidx.coordinatorlayout.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)

BottomAppBar 覆盖按钮

xml android android-layout android-bottomappbar

8
推荐指数
1
解决办法
328
查看次数

在ActionBar项目下方显示工具提示

我尝试了很多但是却找不到任何简单的解决方案.基本上我想在ActionBar项目下面显示一个工具提示气球.

参考图像

android android-actionbar android-toolbar

7
推荐指数
1
解决办法
2369
查看次数

Android Studio 4.1 Canary 6 问题与 kapt 插件(e:java.lang.NoSuchMethodError:org.jetbrains.kotlin.codegen.state.GenerationState)

我使用 Android Studio 4.1 Canary 6 版本并尝试使用apply plugin: 'kotlin-kapt'插件,然后在构建项目期间出现此错误。

e: java.lang.NoSuchMethodError: org.jetbrains.kotlin.codegen.state.GenerationState$Builder.isIrBackend(Z)Lorg/jetbrains/kotlin/codegen/state/GenerationState$Builder;
Run Code Online (Sandbox Code Playgroud)

这里是项目级别的gradle

buildscript {
    ext.kotlin_version = "1.3.70"
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.0-alpha06'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)

这是应用程序级别的gradle

plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'kotlin-android-extensions'
    id 'kotlin-kapt'
}
......
......
dependencies {

 //room database
    implementation 'androidx.room:room-runtime:2.2.5'
    implementation "androidx.room:room-ktx:2.2.5"
    kapt 'androidx.room:room-compiler:2.2.5'
}
Run Code Online (Sandbox Code Playgroud)

android android-studio kotlin-android-extensions

7
推荐指数
1
解决办法
1661
查看次数

Android Studio GitHub 登录“凭据不正确。请求响应。401 未经授权

我无法通过 Android Studio 登录我的 GitHub 帐户。我不知道为什么我会收到这个错误,而且似乎没有太多关于它的信息。我确保安装了 Git,甚至尝试使用令牌执行此操作。见附件图片。任何帮助表示赞赏。提前致谢

登录凭据

令牌

android github android-studio

7
推荐指数
2
解决办法
8353
查看次数

如何隐藏 Android 11 应用中的状态栏?

我遇到的所有隐藏 Android 应用状态栏的方法在 Android 11 中均已弃用。

有谁知道目前可以接受的方法吗?

我还使用 Kotlin 来开发我的应用程序。

android kotlin android-statusbar android-api-levels android-11

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

android-studio android-studio-dir 位置

我正在尝试让 flutter/android studios 在 Linux 上工作,但我在让 flutter 识别我的 android-studio 位置时遇到问题。

\n

我可以运行 android-stuio,但是当我尝试通过 android-studio-dir 参数告诉 flutter 我的安装位置时,我得到了一些不起作用的东西。

\n
$ flutter doctor\nDoctor summary (to see all details, run flutter doctor -v):\n[\xe2\x9c\x93] Flutter (Channel master, 1.27.0-2.0.pre.78, on Linux, locale en_US.UTF-8)\n[\xe2\x9c\x93] Android toolchain - develop for Android devices (Android SDK version 30.0.3)\n[\xe2\x9c\x97] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)\n    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.\n[!] Android Studio\n    \xe2\x9c\x97 android-studio-dir = ~/Downloads/android-studio/bin/\n    \xe2\x9c\x97 Android …
Run Code Online (Sandbox Code Playgroud)

android-studio flutter

7
推荐指数
2
解决办法
3万
查看次数

围绕轴心点旋转图像

问题很简单:我想围绕某个枢轴点旋转图像.这是我使用的代码:

Matrix matrix = new Matrix();
matrix.setTranslate(bmpWidth/2, 0);
matrix.preRotate(degrees, bmpWidth/2, 0);

Bitmap resizedBitmap = Bitmap.createBitmap(
    bitmap, 0, 0, bmpWidth, bmpHeight, matrix, true);
ImageView imageView = (ImageView) findViewById(R.id.bell);
imageView.setImageBitmap(resizedBitmap);
Run Code Online (Sandbox Code Playgroud)

我从加速计传感器获得旋转度.结果是每次图像围绕其中心点旋转.

android

6
推荐指数
1
解决办法
9644
查看次数

如何在方向改变时保留沉浸模式?

目前在 Activity 类中使​​用此代码块来进入粘性沉浸模式:

override fun onWindowFocusChanged(hasFocus: Boolean) {
    super.onWindowFocusChanged(hasFocus)

    if (hasFocus && android.os.Build.VERSION.SDK_INT > 15) {
        var flags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
                View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
                View.SYSTEM_UI_FLAG_FULLSCREEN
        flags = if (android.os.Build.VERSION.SDK_INT < 19) flags
            else flags or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
        window.decorView.systemUiVisibility = flags
    }
}
Run Code Online (Sandbox Code Playgroud)

当方向切换时,状态栏会回来(甚至不是半透明的)并保持不变,直到拖动,然后再次消失。我真的不明白这种行为的原因,我该如何解决它?

先感谢您。

android screen-orientation kotlin android-immersive

6
推荐指数
2
解决办法
1602
查看次数

为什么 Android Studio 在 res/drawable-v24 中创建 ic_launcher_foreground 并在 res/drawable 中创建 ic_launcher_background.xml?

首先

我注意到在 Android Studio 中创建一个新项目时它会生成drawable-v24带有ic_launcher_foreground.xml图标的文件夹。

我的问题是:

  1. 如果在 v24 之前引入了vector drawable,那么为什么它将矢量资产drawable-v24放在drawable-v21文件夹中而不是放在文件夹中?

其次

另一个生成的资产是ic_launcher_background.xmlres/drawable文件夹中创建的,后来从mipmap-anydpi-v26/ic_launcher.xml.

  1. 如果它仅用于 API v26+(自适应图标),那么为什么它是在res/drawable文件夹中创建而不是在res/drawable-v24或 中res/drawable-v26?是由于 mipmap 文件夹的某些性质吗?

icons android android-studio android-vectordrawable adaptive-icon

6
推荐指数
1
解决办法
1173
查看次数