0

ラベルのみを含むボタンはほとんどありません。2 つの画像リソースを使用して作成されます (押されたものは、押されていないものよりも少し大きくなります)。

button_image.png
button_image_pressed.png 

およびxml

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

    <item android:drawable="@drawable/button_image" android:state_pressed="false"/>
    <item android:drawable="@drawable/button_image_pressed" android:state_pressed="true"/>

</selector>

そして、これにカスタム TextView を使用したいと思います。ユーザーがテキストに触れたときに TextView の textSize を変更し、テキスト ユーザーが画面を離したときに textSize を元に戻すことは可能ですか?

さまざまな解決策を試しましたが、うまくいきませんでした。

4

1 に答える 1

2

を使ってみることができますonTouchListener()

    textView.setOnTouchListener( new OnTouchListener() {

        @Override
        public boolean onTouch( View v, MotionEvent event ) {

            switch(event.getAction()) {
                case MotionEvent.ACTION_DOWN:
                    textView.setTextSize( ... );
                    break;
                case MotionEvent.ACTION_CANCEL:
                case MotionEvent.ACTION_UP:
                    textView.setTextSize( ... );
            }
            return false;
        }
    } );
于 2012-12-27T22:59:37.487 に答える