2011-08-10 8 views
10

linearLayout의 경우 백그라운드에서 바둑판 식으로 배열 된 이미지와 함께 그라데이션을 사용하고 싶습니다. 이미 모양 XML은그라디언트 및 바둑판 식 이미지가있는 Android 배경

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle"> 
    <gradient android:angle="90" 
     android:endColor="@color/color1" 
     android:startColor="@:color/color2"> 
    </gradient> 
</shape> 

가 어떻게 바둑판 BG 이미지를 추가 않는 배경으로 설정 한?

+0

좋은 설명은이 [link] (http://androidblogger.blogspot.com/2009/01/how-to-have-tiled-background-cont.html)을 참조하십시오. –

+0

나는 그 일을하는 법을 안다. 내가 모르는 것은 그들 모두를 함께하는 방법이다. – Taranfx

+1

네, 죄송합니다. 그러면이 다른 [질문] (http://stackoverflow.com/questions/4159959/android-circular-gradient-alpha-mask)이 도움이 될 수 있습니다. 내가 게시 한 첫 번째 링크에 설명 된대로 비트 맵 XML에서 타일 이미지를 사용하고 다음이 다른 질문처럼 캔버스에 그려 그라데이션을 추가하려고합니다. 희망이 도움이됩니다. –

답변

23

체크 아웃 LayerLists

다음은 myBackground.xml이라고하는 XML 드로어 블이며 res/drawable에 있습니다. 그라데이션 및 바둑판 식 배경을 설정하려는 View의 배경으로 설정하십시오.

타일 이미지는 그라디언트 상단에 있습니다. LayerList에서 나중에 지정되므로 분명히 위쪽에 있으면 png 이미지 타일에 약간의 투명도가 필요합니다. 김프 또는 포토샵과 같은 이미지 편집 응용 프로그램에서). (이것은 한 tileable의로, 250 픽셀 광장 - 우리가 초대형 필요가 없습니다)

<?xml version="1.0" encoding="utf-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item> 
     <shape android:shape="rectangle"> 
      <gradient 
       android:type="radial" android:gradientRadius="500" 
       android:startColor="#17568A" 
       android:endColor="#494C4F" /> 

     </shape> 
    </item> 
    <item> 
     <bitmap 
      android:src="@drawable/tile_classy_fabric" 
      android:tileMode="repeat" /> 
    </item> 
</layer-list> 

는 "tile_classy_fabric는"내 res/drawable 폴더에 "tile_classy_fabric.png"라는 파일을 의미합니다.

관련 문제