【发布时间】:2016-12-20 04:59:06
【问题描述】:
使用 XML 选择器为 Click 事件更改 Android 按钮更改图像。像这样。
StartButtonSelector.XML
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_pressed="true" android:drawable="@drawable/start_button_pushed" />
<item android:drawable="@drawable/start_button" />
</selector>
和这样的布局 XML 文件。
main_activity.xml
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/startButton"
android:layout_marginBottom="10dp"
android:layout_marginTop="8dp"
android:background="@drawable/start_btn_selector"/>
现在。我计划使用毕加索图像库进行图像缓存。以避免内存不足错误。所以这是我的场景。这个怎么做。提前致谢。
【问题讨论】:
-
你可以参考这个链接:stackoverflow.com/questions/21158425/… 缓存 Glide 比 Picasso 更好。我已经为此推荐了 Glide。
-
不工作 Picasso.with(this).load(R.drawable.start_btn_selector).into(startBtn);
标签: android xml imageview picasso