5

I would like to have this

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true" style="@style/font_size_increase"/>
</selector>

and it seems that this one is not supported anymore.

I wonder if there is another way to increase the text size (in xml) when it is pressed?

Many thanks!

Huy Than
  • 1,538
  • 2
  • 16
  • 31

1 Answers1

1

UPDATED CODE-- Create your own dimens.xml file and then set it on selector like this

 <resources>
     <item name="text_size" type="integer">10dp</item>
  </resources>

Then use in java code-

 textView.setOnTouchListener( new OnTouchListener() {

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

        switch(event) {
            case MotionEvent.ACTION_DOWN:
                textView.setTextSize(this.getResources().getDimension(R.id.text_size));
                break;
            case MotionEvent.ACTION_CANCEL:
            case MotionEvent.ACTION_UP:

        }
        return false;
    }
} );
Gopal Singh
  • 1,133
  • 1
  • 9
  • 25
  • sorry, but this is what I asked: it seems that style is not supported in selector anymore. Your code doesn't work to me. Have you tried this code? – Huy Than Mar 19 '15 at 15:53