gpt4 book ai didi

具有级别列表的 android ImageView 不起作用

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:07:22 25 4
gpt4 key购买 nike

start_background.xml

<?xml version="1.0" encoding="utf-8"?>
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@color/grey"
android:maxLevel="1"
/>
<item
android:drawable="@color/grey"
android:maxLevel="2"
/>
<item
android:drawable="@color/grey"
android:maxLevel="3"
/>

</level-list>

开始 Activity .xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"

android:id="@+id/page"
>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/start_background"
android:id="@+id/start"
/>
</LinearLayout>

Java代码

ImageView image= (ImageView)findViewById(R.id.start);
LevelListDrawable background=(LevelListDrawable)image.getBackground();
background.setLevel(3);

但是它不能改变背景,我试过把android:background改成android:src,也没用。

日志:

2690-2705/com.jifa.runandcatch2 W/EGL_emulation﹕     eglSurfaceAttrib not implemented
2690-2705/com.jifa.runandcatch2 W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xae0e1de0, error=EGL_SUCCESS

如何解决,谢谢。

最佳答案

使用:

image.setImageLevel(3);

而不是:

LevelListDrawable 背景=(LevelListDrawable)image.getBackground();background.setLevel(3);

关于具有级别列表的 android ImageView 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28868531/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com