Android Studio學習手冊-ImageView, ImageButton

Andreea
May 29, 2021

--

示意圖
  1. 將三張圖片拉到drawable(app>res>drawable)

2. 建立xml布局(參考上面示意圖)

4 textviews

1 imageview

3 imagebutton

詳細xml code請點擊這裡

3. strings.xml加入以下code

<string name="app_name">猜拳遊戲</string>
<string name="player">玩家出拳</string>
<string name="computer">電腦出拳</string>
<string name="scissors">剪刀</string>
<string name="stone">石頭</string>
<string name="paper">布</string>
<string name="win">恭喜,你贏了!</string>
<string name="lose">很可惜,你輸了!</string>
<string name="draw">平手!</string>

4. java檔:當imageButton被點擊時,出現結果(set imageView)

詳細java code請點擊這裡

是不是很簡單呢?

更多關於Android studio的文章:

RadioGroup, RadioButton1

RadioGroup, RadioButton2

NumberPicker數字轉輪

CheckBox

layout_constraintVertical_bias, layout_constraintHorizontal_bias

ListView選單

Fragment動態控制

--

--