2014-11-18 2 views
2

누구나 ColorControlNormal 이외의 것으로 Theme.Material 내의 스크롤바 색상을 변경하는 방법을 알고 있습니까? 이동하여 themes_material을 보면 특정 스크롤 막대 특성이 있음을 알 수 있지만 스크롤 막대 색을 재정의하는 직접적인 방법은 없으며 전체 드로어 블만 재정의 할 수 있습니다. 내 목적을 위해, 나는 시스템이 사용하고있는 스크롤 바 drawleable (같은 9 패치)을 유지하고 싶습니다. 단지 colorControlNormal 색상과 다른 색상으로 색칠하고 싶습니다.안드로이드 5.0 스크롤 바 색상 변경

답변

2

내 테마의 전체 scrollbarThumbVertical 또는 scrollbarThumbHorizontal 속성을 다른 드로어 블에 오버라이드 할 수있는 것으로 나타났습니다.

<style name="AppTheme" parent="@android:style/Theme.Material"> 
    <item name="android:scrollbarThumbVertical">@drawable/scrollbar_handle_material</item> 
</style> 

다음 당김-V21 폴더 내에 사용자가 시스템에서 여기에있는 동일한 XML있을 것입니다 : 당신은 같을 것이다 AppTheme에서 당신이 색조 색상을 설정합니다

<?xml version="1.0" encoding="utf-8"?> 
<!-- Copyright (C) 2014 The Android Open Source Project 
Licensed under the Apache License, Version 2.0 (the "License"); 
you may not use this file except in compliance with the License. 
You may obtain a copy of the License at 
     http://www.apache.org/licenses/LICENSE-2.0 
Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, 
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
See the License for the specific language governing permissions and 
limitations under the License. 
--> 

<nine-patch xmlns:android="http://schemas.android.com/apk/res/android" 
    android:src="@drawable/scrollbar_handle_mtrl_alpha" 
    android:tint="#A4A4A4" /> 

스크롤바가 5.0 이상의 기기에 있어야 할 색상입니다. Google은 scrollbar_handle_mtrl_alpha 애셋을 공개적으로 액세스하지 않으므로 제공하려는 다른 모든 밀도와 함께 PATH_TO_ANDROID_SDK/platforms/android-21/data/res/drawable-xxhdpi/scrollbar_handle_material_alpha에서 가져와야합니다. 나는 참고 여기 드로어 블-xxhdpi 자산을 넣어 것입니다 :

enter image description here

너희들이 이렇게 많은 일을 오버라이드 (override) 할 필요없이이 작업을 수행하는 다른 방법을 찾을 수 있으면 알려 주시기 바랍니다.