[問題] RadioButton對齊問題?

看板AndroidDev作者 (叛帝)時間11年前 (2014/02/20 15:50), 編輯推噓0(0010)
留言10則, 4人參與, 最新討論串1/1
最近我在做生活用的APP 跟大多數APP一樣下方有按鈕可以使用 但是我採用的是RadioButton去做 但是我碰到一個問題 就是我給每一個Button套好style的時候 想要再調整間距..他的圖片卻往左靠.. 怎麼調整都一樣... 後來就直接修改圖片的大小去座間距了.. 我有試著使用rameLayout去排版 這樣就可以強制圖片置中又可以調整間距了.. 但是這樣做我的Button會沒有任何反應.. 一定要把Button套到RadioGruop下才會有反應.. 也就是說在RadioGroup與RadioButton中間有格Layout就會造成BUG? <RadioGroup android:id = "@+id/radioGroup1" android:layout_width = "match_parent" android:layout_height = "wrap_content" android:background = "@color/gray_percent" android:orientation = "horizontal" > <FrameLayout android:layout_width = "0dip" android:layout_height = "wrap_content" android:layout_weight = "1" > <RadioButton android:id = "@+id/radio0" android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:layout_gravity = "center_horizontal" android:button = "@drawable/rb_temp1" android:checked = "true" android:gravity = "center" /> </FrameLayout> <FrameLayout android:layout_width = "0dip" android:layout_height = "wrap_content" android:layout_weight = "1" > <RadioButton android:id = "@+id/radio0" android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:layout_gravity = "center_horizontal" android:button = "@drawable/rb_temp1" android:gravity = "center" /> </FrameLayout> </RadioGroup> 有沒有鄉民能給些建議呢? -- ══ ◣◢◣◢Vocaloid╮ ◤◥ ◢◢ quetzal◥◥ ◥◤ ◣◢ ║ ║ ● ●▼ ● ●◥ ● ● ; ︽﹨ ◥▼ ▃▃ ║ ● ● ● ● ド! ███▆≡ ▅▅ ══◣︶●══ ◥◣ / / / ══ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.34.164.154

02/21 00:55, , 1F
RadioButton: android:background="@null" ??
02/21 00:55, 1F

02/21 09:43, , 2F
應該是說...有沒有辦法讓Framelayout不影響BUTTON
02/21 09:43, 2F

02/21 09:44, , 3F
或是有方法能調整button的位置而不會失去正常功能
02/21 09:44, 3F

02/21 10:34, , 4F
Framelayout裡面再包一層Relative或LinearLayot排版
02/21 10:34, 4F

02/21 10:45, , 5F
之前有遇過,後來是使用TextView加上
02/21 10:45, 5F

02/21 10:45, , 6F
android:drawableTop之類的屬性解決的
02/21 10:45, 6F

02/21 10:46, , 7F
所以RadioGroup的功能是自己寫@@
02/21 10:46, 7F

02/21 13:32, , 8F
恩恩我試試看包兩層~..其實我在想乾脆就不要用這個BUTTON
02/21 13:32, 8F

02/21 13:33, , 9F
直接用普通的button去模擬編寫他的狀態就好了LOL
02/21 13:33, 9F

02/21 14:49, , 10F
有圖的話我是用兩層加imageview這樣比較不會跑圖
02/21 14:49, 10F
文章代碼(AID): #1J1RF2MC (AndroidDev)