我想要这个
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" style="@style/font_size_increase"/>
</selector>
而且这个好像不支持了。
我想知道是否有另一种方法可以在按下时增加文本大小(在 xml 中)?
非常感谢!
最佳答案
更新代码-- 创建您自己的 dimens.xml 文件,然后像这样在选择器上设置它
<resources>
<item name="text_size" type="integer">10dp</item>
</resources>
然后在java代码中使用-
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;
}
} );
关于android - 当 state_pressed = true 时更改 <selector> 中的文本大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29099396/