2011-11-10 17 views

答えて

1

Androidでは自動でも可能です。例に従ってください。あなたは、任意の画像ファイルを "state_orange" を置き換えることができます。

をコントロールするために:

android:background="@color/back_color_selector_blue_gradient" 

back_color_selector_blue_gradient.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/state_orange" /> 
    <item android:state_selected="true" android:drawable="@drawable/state_orange" /> <!-- focused --> 
    <item android:drawable="@drawable/background07" /> <!-- default --> 
</selector> 

background07.xml:

<?xml version="1.0" encoding="utf-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 


    <item> 
     <shape android:shape="rectangle"> 
      <gradient android:startColor="@color/grayBlue3" 
       android:endColor="@color/lightBlue" android:angle="270" 
       android:centerColor="@color/lightBlue" /> 
      <!-- border width and color --> 
      <stroke android:width="1dp" android:color="#FFDDDDDD" /> 
      <padding android:left="1dp" android:top="1dp" android:right="1dp" 
       android:bottom="1dp" /> 
     </shape> 
    </item> 

</layer-list> 

state_orange。 xml:

<?xml version="1.0" encoding="UTF-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle"> 
    <solid android:color="@color/orange" /> 
</shape> 
+0

多くのありがとう...私は何か@色を聞くことができます..それはAndroidのプロジェクトファイルの標準resourseディレクトリではない..右か? – user836026

+0

はいこれはAndroidの標準リソースディレクトリです。 – breceivemail

+0

しかし、私はこのエラーが表示されます:エラー:指定された名前に一致するリソースが見つかりませんでした(値 '@ color/lightBlue'の 'centerColor')。 以下のように: – user836026

関連する問題