android的ml中怎麼實現按鈕按下去變顏色

時間 2021-12-22 15:15:59

1樓:兄弟連教育

在res下建一個名為xml的資料夾,然後建一個xml檔案,名字隨便,然後將

這段**複製進去,這裡面的play_down和play是兩張**。

然後再main.xml裡設定imagebutton的android:src="@xml/select",其中select就是剛才在xml下建的xml檔名。

在上面的xml中是根據imagebutton的是否被按下的狀態來改變imagebutton背景的。

在activity裡對按鈕的事件進行監聽就行了,在事件裡設定按鈕的背景。

2樓:幸福專賣店

android開發中如何做到ml多螢幕適配

高度適配問題,最外層layout你可以採用linearlayout 裡面包含 的控制元件可以將 layout heght 設定為0dp並且加上 layout weight 這個屬性layout weight表示當前這個view佔當前佈局的比重比如有上面的四個文字框佔總螢幕的4 5,下面一行文字佔1 ...

android如何實現拋撒金幣的動畫效果

這是金幣 目前的話 建立一個animationset物件 animationset是存放多個animations的集合 animationset animationset new animationset true translateanimation translateanimation new ...

android中imagebutton的src設定顯示不出

神祕偵探 android中 imageview imagebutton imageswitch等image 控制元件都有一個屬性叫 src src是表示指定影象的資源,在 中的設定方式 1 imageview.setimagebitmap bitmap bmp 傳入引數為bitmap 2 image...