Huy*_*han 5 android android-layout
我想要这个
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" style="@style/font_size_increase"/>
</selector>
Run Code Online (Sandbox Code Playgroud)
而且似乎不再支持这个了.
我想知道是否有另一种方法可以在按下时增加文本大小(以xml为单位)?
非常感谢!
更新代码-- 创建您自己的dimens.xml 文件,然后将其设置在选择器上,如下所示
<resources>
<item name="text_size" type="integer">10dp</item>
</resources>
Run Code Online (Sandbox Code Playgroud)
然后在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;
}
} );
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1159 次 |
| 最近记录: |