2011-05-07 3 views
2

Android 앱에서 선형 레이아웃의 배경을 수평 및 수직으로 반복하는 것은 매우 간단합니다. tileMode를 사용해야합니다 (How to make android app's background image repeat 참조).Android 앱에 수직 타일 (유일한) 배경을 추가하는 방법

xml 파일의 tileMode를 사용하면 세로 축에서만 배경 이미지를 반복 할 수 없습니다. tileModeY가 있지만 xml에서 액세스 할 수 없습니다.

"반복"속성을 수정하려고합니다. 나는 또한 드로어 블/welcomebackground.png의 이미지와 드로어 블/사진 welcomebackgroundpattern.xml의 이미지에 대한 XML 파일을했습니다

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:id="@+id/mainMenuLayout" 
       android:orientation="vertical" 
       android:gravity="center_horizontal" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent"> 

:

내가 선형 레이아웃과 main.xml에 파일을했습니다 :

public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 

    Resources res = getResources(); 
    BitmapDrawable background = (BitmapDrawable) res.getDrawable(R.drawable.welcomebackground); 
    background.setTileModeY(Shader.TileMode.REPEAT); 
    (new View(this)).setBackgroundResource(R.drawable.welcomebackground); 
    } 

을하지만 내 배경은 여전히 ​​검은 색 : 내 활동에

<?xml version="1.0" encoding="utf-8"?> 
<bitmap xmlns:android="http://schemas.android.com/apk/res/android" 
     android:src="@drawable/welcomebackground" 
     android:dither="true" /> 

나는 이것을 시도했습니다. 물론 xml에서 추가 할 수 있지만 x 축과 y 축 모두에서 반복됩니다.

제 질문은 매우 간단합니다. 내 활동에서 수직적으로 "환영 배경"이미지를 어떻게 반복 할 수 있습니까?

나는 해결책을 발견했습니다
+0

가능한 중복 http://stackoverflow.com/questions/3657793/android-bitmap-tile-on-x-only) – fredley

답변

관련 문제