2011-07-04 15 views
0

ActionDownActionUpの色を元の色に合わせて変更しました。text/buttonは現在transparentになります。クリックするとAndroidのテキストの色が変わります

私のスタイルスクリプト:

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
<style name="MenuFont"> 
    <item name="android:textSize">20sp</item> 
    <item name="android:textColor">#CDCDCD</item> 
    <item name="android:textStyle">normal</item> 
    <item name="android:clickable">true</item> 
    <item name="android:layout_weight">1</item> 
    <item name="android:gravity">left|center</item> 
    <item name="android:paddingLeft">35dp</item> 
    <item name="android:layout_width">175dp</item> 
    <item name="android:layout_height">fill_parent</item> 
</style> 

オリジナルの作業スクリプト:

package com.pxr.tutorial.menu; 

import android.view.MotionEvent; 
import android.view.View; 
import android.widget.TextView; 

public class CustomTouchListener implements View.OnTouchListener {  
public boolean onTouch(View view, MotionEvent motionEvent) { 

    switch(motionEvent.getAction()){    
     case MotionEvent.ACTION_DOWN: 
     ((TextView) view).setTextColor(0xFF6A5ACD); 
      break;   
     case MotionEvent.ACTION_CANCEL:    
     case MotionEvent.ACTION_UP: 
     ((TextView) view).setTextColor(0xFFFFFF00); 
      break; 
    } 

    return false; 
} 
} 

新しいスクリプト:

package com.synamegames.orbs; 

import android.view.MotionEvent; 
import android.view.View; 
import android.widget.TextView; 

public class CustomTouchListener implements View.OnTouchListener {  
public boolean onTouch(View view, MotionEvent motionEvent) { 

    switch(motionEvent.getAction()){    
     case MotionEvent.ACTION_DOWN: 
     ((TextView) view).setTextColor(0x4F4F4F); 
      break;   
     case MotionEvent.ACTION_CANCEL:    
     case MotionEvent.ACTION_UP: 
     ((TextView) view).setTextColor(0xCDCDCD); 
      break; 
    } 

    return false; 
} 
} 

元のテキストの色と一致するように16進コードを変更しました。私がしたら、そのテキストはクリックされると透明になりました。私は何を間違えたのですか?

答えて

2

0x4F4F4Fの代わりに0xFF4F4F4Fを使用してください。 0xCDCDCDの代わりに0xFFCDCDCD。

00..FFは、透過性を表すアルファ値です。

関連する問題