Van*_*Van 8 java eclipse android
我想使用我为我的应用程序绘制的自定义按钮图像,但这样做我需要使用不同的图像来聚焦按钮而另一个按下它.
我遇到了选择器标签但由于某种原因它不喜欢它.Eclipse抱怨"渲染库已损坏".我得到的错误是这样的:
Broken rendering library; unsupported DPI. Try using the SDK manager to get updated.
Run Code Online (Sandbox Code Playgroud)
我有,我已经更新了过去10的每个API.如果重要,我的目标API是15,我的编译API是17.
如果我无法使用它,我可以简单地使用Button标签并可能在Java src代码中更改它吗?
使用像这样的自定义布局
<?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/pressed"></item>
<item android:state_focused="true" android:drawable="@drawable/focus"></item>
<item android:drawable="@drawable/normal"></item>
</selector>
Run Code Online (Sandbox Code Playgroud)
另请注意,选择器应该以这种特定方式定义,否则它们会出现问题。即
1)state_pressed
2)state_focused ( work only if you scroll to that button using the hardware key)
3)drawable i.e. normal
Run Code Online (Sandbox Code Playgroud)
如果您更改了选择器的顺序,那么它将不起作用。记住它的一种简单方法是想象一部全键盘手机 - 首先我看到按钮 ( normal),然后使用箭头键 ( state_focused) 移动到该特定按钮,然后按下该按钮 ( state_pressed)。现在倒着写。
| 归档时间: |
|
| 查看次数: |
362 次 |
| 最近记录: |