シンプルなpngファイルのボタンがいくつかあります。normal
デフォルトの状態のように見えます。pressed
すべてのボタンの状態を動的に作成したい。主な目的は、png とデザイナーでの作業を避けることです。Pressed
xml または java を使用して状態を作成するにはどうすればよいですか?
1 に答える
0
ただし、状態に基づいて異なる画像をトリガーするための XML コードを探している場合は、res->drawable フォルダーに配置されたセレクターがそのトリックを実行します。
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:state_enabled="false"
android:drawable="@drawable/gallerydisabled" />
<item
android:state_pressed="true"
android:state_enabled="true"
android:drawable="@drawable/gallerypressed" />
<item
android:state_enabled="true"
android:drawable="@drawable/gallerynormal" />
</selector>
于 2013-05-08T14:03:53.217 に答える