':'에 해당되는 글 1건

  1. 안드로이드 앱 개발 - 배경을 연속된 패턴으로 바꾸기(android:background)
안드로이드에서 xml 에서 android:background를 통해 배경화면을 변경할 수 있습니다. 이런 경우에는 배경으로 지정된 사진을 화면에 맞게 늘여서 보여줍니다. 이게 그냥 사진이라면 상관 없지만 패턴같은 경우에는 적합하지 않습니다.

안드로이드 앱 개발 - 배경을 연속된 패턴으로 바꾸기(android:background)
 
1. drawable 폴더에 패턴 배경으로 쓸 이미지를 넣어 줍니다.(ex. drawable-xhdpi/back.png)


2. drawable 폴더에 새로운 background.xml 파일을 만들고 xml에다가 아래와 같은 구문을 넣어 줍니다.


<?xml version="1.0" encoding="UTF-8"?>

<bitmap xmlns:android="http://schemas.android.com/apk/res/android"

    android:src="@drawable/back" <-- 파일 이름

    android:tileMode="repeat"

/>


 
3. 배경을 지정할 래이아웃 xml에서 맨 위의 레이아웃 정의하는 부분에 아래 구문을 추가해줍니다.

  android:background="@drawable/background"  

예시 ) 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent"

    android:background="@drawable/background"

    android:layout_height="match_parent" > 


4. 패턴 배경이 적용된 것을 확인할 수 있습니다.:)


도움이 되셨나요?
그럼 손가락을 눌러주세요:)