Re: [問題] 更改TimePicker 顏色 分格線顏色
※ 引述《LiHowDie (我要堅強 我可以)》之銘言:
: 請問有人知道怎麼更改
: TimePicker 的 文字顏色 還有 分格線顏色嗎?!
: 上網看了別人講的 沒有一個可以試成功的 =..=
: 都是style parent那邊錯誤
可以 recursive 的方式手動設定 background 或是背景,
TimePicker 是一個包含兩個 NumberPicker 的 LinearLayout 和 一個 Button 組成,
NumberPicker 是兩個 ImageButton 及一個 EditText 組成,
可以依照層級呼叫的次數或是 component 的 resource ID 來判斷要怎樣改,
這兩個 widget 的 xml 格式請參考
frameworks/base/core/res/res/layout/time_picker.xml
frameworks/base/core/res/res/layout/number_picker.xml
private boolean applyCustomizedTheme(ViewGroup parent) {
for(int i=0; i<parent.getChildCount(); i++) {
View child = parent.getChildAt(i);
if(child instanceof ViewGroup) {
// TimePicker 或是 NumberPicker 的外皮
// 改完之後繼續往內層找
applyCustomizedTheme( (ViewGroup) child);
} else if(child != null) {
// 不是 ViewGroup 也不為 null 那就是最底層的 component
if(child instanceof EditText) {
// NumberPicker 中間的文字
} else if(child instanceof ImageButton) {
if(child.getId() == getResources().getIdentifier(
"increment", "id", "android") {
// NumberPicker 的增加紐
} else if(child.getId() == getResources().getIdentifier(
"decrement", "id", "android") {
// NumberPicker 的減少紐
}
}
}
}
}
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 118.163.109.212
※ 文章網址: http://www.ptt.cc/bbs/AndroidDev/M.1400235189.A.A5A.html
推
05/19 17:37, , 1F
05/19 17:37, 1F
→
05/19 17:37, , 2F
05/19 17:37, 2F
推
05/19 18:06, , 3F
05/19 18:06, 3F
推
05/19 18:20, , 4F
05/19 18:20, 4F
→
05/19 18:21, , 5F
05/19 18:21, 5F
推
05/20 10:46, , 6F
05/20 10:46, 6F
→
05/20 10:47, , 7F
05/20 10:47, 7F
→
05/20 10:47, , 8F
05/20 10:47, 8F
→
05/20 10:48, , 9F
05/20 10:48, 9F
→
05/20 10:49, , 10F
05/20 10:49, 10F
→
05/20 10:49, , 11F
05/20 10:49, 11F
→
05/20 10:50, , 12F
05/20 10:50, 12F
→
05/20 10:50, , 13F
05/20 10:50, 13F
推
05/20 11:01, , 14F
05/20 11:01, 14F
→
05/21 13:12, , 15F
05/21 13:12, 15F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):