반응형
배경을 아래 사진처럼 대각선으로 그라데이션 없이 나눠주고 싶었다.

drawable에 backgroundcolorsetting.xml 파일을 하나 만들어준다
[backgroundcolorsetting.xml]
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="100dp"
android:width="100dp"
android:viewportHeight="100"
android:viewportWidth="100">
<path
android:name="light_triangle"
android:fillColor="#7983D7"
android:pathData="M 0,0 L 100,0 0,100 z" />
<path
android:name="dark_triangle"
android:fillColor="#8790DB"
android:pathData="M 100,0 L 0,100 100,100 z" />
</vector>
이후 저 배경색의 레이아웃을 사용할 xml파일에 와서 작성해줍니다.
[activity_main.xml]
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/backgroundcolorsetting"
android:orientation="vertical">
코드를 보시면 background="@drawable/작성하신 레이아웃이름" 을 입력해주시면 됩니다
그라데이션을 주시고 싶으시면 아래 코드를 활용해서 작성하시면 됩니다

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="45"
android:type="linear"
android:startColor="#247dea"
android:endColor="#879000"/>
</shape>
반응형
'앱 개발 > Java' 카테고리의 다른 글
안드로이드 연결된 wifi ssid 정보 얻기 (0) | 2022.07.15 |
---|---|
안드로이드 토글 버튼 on/off (아이폰 스타일) (1) | 2022.06.07 |
[안드로이드] 웹 서버에 데이터 요청 (Open API 활용) (0) | 2022.03.30 |
[안드로이드] 서버에 데이터 요청 및 응답 (소켓 통신) (0) | 2022.03.29 |
[안드로이드] DB insert, select, delete 문 사용법 (간단한 예제 공유) (0) | 2022.03.25 |