Android の
TextView内のある座標をタッチしたら
MotionEvent.ACTION_DOWN)で
ボタンの背景色が変わり
MotionEvent.ACTION_UP)で
元の色に戻る
というクラスを作成したところ
背景色が変わると
ボタンのサイズが変わってしまいます。(縦横共)
また、背景色の表記を以下のようにしないと動作しませんでした。
背景色変更:
java
1 2if( xxx == 0 && yyy == 0 ){ A.setBackgroundColor(Color.parseColor("#FFB802")); }
背景色元に戻す:
java
1if( xxx == 0 && yyy == 0 ){ A.setBackgroundColor(0xff555555); }
ボタンのサイズが変わらない方法を教えて下さい。
また、setBackgroundColor等の使い方が間違っているのでしたら
正しい使用法をお教え下さいますよう、お願いします。
Android API:4.03
Eclipse Version: Luna Service Release 2 (4.4.2)
xml
1margin,paddingは未指定 2weightで均等配置です。 3 4 <LinearLayout 5 android:id="@+id/BB" 6 android:layout_width="match_parent" 7 android:layout_height="wrap_content" 8 android:orientation="horizontal" 9 android:layout_below="@+id/AA"> 10 11` <Button 12 android:id="@+id/A" 13 style="?android:attr/buttonStyleSmall" 14 android:layout_width="0dp" 15 android:layout_height="wrap_content" 16 android:layout_weight="1" 17 android:text="A" 18 android:textSize="13sp"/> 19 . 20 . 21 .(横一列に6個) 22 . 23 </LinearLayout> 24
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2015/09/04 02:53
2015/09/04 04:17
2015/09/04 05:28
2015/09/04 09:15