답변
Please create a drawable file and put the below code in it.
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="rectangle" >
<size android:height="20dp" />
<solid android:color="#F66D08" />
</shape>
</item>
<item android:top="50dp">
<shape android:shape="rectangle" >
<gradient android:endColor="#AD1B1D"
android:startColor="#E2360A"
android:angle="270" />
</shape>
</item>
</layer-list>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:gravity="center"
android:background="#F66D08"
android:layout_width="match_parent"
android:layout_height="20dp">
</LinearLayout>
<LinearLayout
android:background="@drawable/introslidergradiant"
android:layout_width="match_parent"
android:layout_height="100dp"></LinearLayout>
</LinearLayout>
그리고 만들 drawble 입술 introslidergradiant.xml 이름을 가진 파일 :
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<gradient
android:angle="90"
android:startColor="#A31720"
android:endColor="#E1350B"
android:type="linear" />
</shape>
</item>
</selector>
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/listview_background_shape">
<stroke android:width="2dp" android:color="#ff207d94" />
<padding android:left="2dp"
android:top="2dp"
android:right="2dp"
android:bottom="2dp" />
<corners android:radius="5dp" />
<solid android:color="#ffffffff" />
</shape>
당신은 내 새로운 XML 파일을 만들 수 있습니다 드로어 블 폴더를 만들고 위의 코드를 추가 한 다음 rectangle.xml로 저장하십시오.
레이아웃 내부에서 사용하려면 android : background 속성을 새로운 드로어 블 모양으로 설정하십시오. 우리가 정의한 모양에는 치수가 없으므로 레이아웃에 정의 된보기의 크기를 사용합니다.
그래서 모두 함께 넣어 마지막으로<View
android:id="@+id/myRectangleView"
android:layout_width="200dp"
android:layout_height="50dp"
android:background="@drawable/rectangle"/>
; 이미지 뷰의 경우 android : src를 사용하지만이 사각형을 어떤 뷰의 배경으로도 설정할 수 있습니다. 즉, 사각형을 ListViews, TextViews ... 등의 배경으로 사용할 수 있습니다.
는 다음과 같은 코드를 사용 드로어 블
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<gradient
android:type="linear"
android:startColor="#FFFF820D"
android:endColor="#FFA32815"
android:angle="90"/>
</shape>
에서 XML 파일을해야 아니면 그냥 색상을 설정할 자신의 그라데이션 here을 생성하고 안드로이드 옵션을 선택하고 당신을 위해 그라디언트를 생성 할 수 있습니다 .
층 목록이
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<size
android:width="40dp"
android:height="40dp" />
<solid android:color="#F86F05" />
</shape>
</item>
<item android:top="10dp">
<shape android:shape="rectangle">
<size
android:width="30dp"
android:height="30dp" />
<solid android:color="#B31F19" />
</shape>
</item>
</layer-list>
와 동일의 스크린 샷을 해결하는데 사용될 수있다. 대신 단색의 그라데이션하려면
, 그라데이션 및 때문에 StartColor, endColor와 각도를 설정하는 고체 변경합니다.
완벽하게 보입니다. 좋은 접근을 위해'gradient'를 추가하십시오 –
사용 '' –
SripadRaj