2017-03-07 3 views
0

내 회 전자의 배경색을 흰색으로 변경하려고합니다. 그것이 내가 스피너에게주고 싶은 유일한 변화이지만, 모든 해결책은 커스텀 스피너를 만들거나, 스타일을 변경하거나, 색상을 변경하기 위해 길고 복잡하게 다른 프로세스를 필요로합니다. 색상을 쉽게 바꿀 수있는 방법이 있습니까? 드로어 블을 생성하고 배경으로 설정하는 방법을 즐겼습니다. 솔루션 아래에서 api> = 23에서 작동하는 것으로 나타 났지만 최소 19 분이 필요합니다. 쉬운 방법이 있습니까? 아니면 색상을 변경하기 위해 맞춤 회 전자를 만들어야합니까? 이것은 내가 그것을 보이게하려고 노력하고있는 것이다. 너비/높이를 설정하지 않고 단순화 된 버전을 사용Android Spinner Color

Using drawable listed below for >= 23 api

<?xml version="1.0" encoding="utf-8"?> 
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
     <item> 
      <color android:color="@color/splashColor" /> 
     </item> 

     <item android:gravity="center_vertical|right" android:right="8dp"> 
      <layer-list> 
       <item android:width="12dp" android:height="12dp" android:gravity="center" android:bottom="11dp"> 
        <rotate android:fromDegrees="45"> 
         <shape android:shape="rectangle"> 
          <solid android:color="#000000" /> 
          <stroke android:color="#aaaaaa" android:width="1dp"/> 
         </shape> 
        </rotate> 
       </item> 

       <item android:width="30dp" android:height="10dp" android:bottom="21dp" android:gravity="center"> 
        <shape android:shape="rectangle"> 
         <solid android:color="@color/splashColor"/> 
        </shape> 
       </item> 
      </layer-list> 
     </item> 
    </layer-list> 

(> = 23 필요)이

<?xml version="1.0" encoding="utf-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > 
    <item> 
     <shape> 
      <solid android:color="@android:color/white" /> 
     </shape> 
    </item> 
    <item> 
     <bitmap 
      android:gravity="end" 
      android:src="@drawable/arrow_dropdown" /> 
    </item> 
</layer-list> 

처럼 보이지만 전체 화면이 보이는 만들기, 높이가 너무 큰 수 떨어져서. 나는 높이를 바꾸는 방법을 모르고있다. pre 23

답변

0

결국 나는 두 번째 방법을 사용했고 수동으로 스피너 높이를 설정했습니다. 마지막으로 스피너 코드가 어떻게 생겼는지 보여줍니다.

<Spinner 
     android:layout_width="match_parent" 
     android:layout_height="35dp" 
     android:background="@drawable/custom_spinner" 
     android:id="@+id/type" /> 

custom_spinner

<?xml version="1.0" encoding="utf-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > 
    <item> 
     <shape> 
      <solid android:color="@android:color/white" /> 
     </shape> 
    </item> 
    <item> 
     <bitmap 
      android:gravity="end" 
      android:src="@drawable/arrow_dropdown" /> 
    </item> 
</layer-list> 
0

테마 속성을 설정할 수있다.

사용자 정의 네임 스페이스를 사용하고 설정하십시오.

Ex. custom_style은 다음과 같이 당신의 스타일 디렉토리에 정의되어

<ProgressBar 
.... 
app:theme="@style/custom_style" 
/> 

:

<style name="custom_style" parent="Theme.AppCompat"> 
     <item name="colorControlNormal"><!--this color is not of importance --></item> 
     <item name="colorControlActivated">#FFFFFF</item> 
    </style> 

는 진행 막대 색상에 흰색 추가했다. 등급 표시 줄에서 작동합니다. 가정은 진보 바에 대해서도 잘해야합니다.