Re: [問題] 更改TimePicker 顏色 分格線顏色

作者: csk (:))   2014-05-16 18:13:02
※ 引述《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 的減少紐
}
}
}
}
}
作者: LiHowDie (我要堅強 我可以)   2014-05-19 17:37:00
這內容我也有看到 只是我不曉得那個參數viewGroup要丟什麼進去!!!我大概知道了 我研究一下 謝謝你唷!!但是好像沒有ImageView呢!!打錯 是 ImageButton很奇怪的是 我怎麼解析他 最後是有解析到1個NumberPicker他後面ID有寫是Hour 然後 一個 TextView 他是Divider他應該就是那個 冒號 !! 然後最後一個也是NumberPicker他是Minute 一共這三個Child但是問題來了 這兩個NumberPicker 怎麼解析 都只能抓到他當前數字的EditText 不能抓到其他的 而且該顏色只有TimePicker 選項內的時間!! 等於其他顏色都是白色而且只要移動數字 顏色就不見了 ....怎麼抓都抓不到ImageButton
作者: csk (:))   2014-05-21 13:12:00
把 child 轉型之後就可以使用該類的函式了

Links booklink

Contact Us: admin [ a t ] ucptt.com