![](/img/trans.png)
[英]Change the text size of a TextView and a Column in TableLayout in Android
[英]Android change text size in TextView on click
我有幾個按鈕只包含標簽。 它們是使用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?
我嘗試了不同的解決方案,但它們沒有用。
您可以嘗試使用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;
}
} );
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.