1
저는 Button
이며 그라데이션 드로어 블을 배경으로 설정합니다. 그라디언트 드로어 블이있는 버튼에는 높이가 누락되었지만 다른 모든 버튼에는 높이가 있습니다.Android : 그라디언트 드로잉을 배경으로 설정할 때 높이가 누락되었습니다.
그래디언트 드로잉이 가능한 버튼의 높이가 누락 된 이유는 무엇입니까? 그리고 이것을 해결할 수있는 쉬운 방법이 있습니까?
내 코드는 다음과 같습니다
gradient.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:type="radial"
android:gradientRadius="250dp"
android:startColor="@color/blue"
android:endColor="@color/red"/>
<corners android:radius="@dimen/round_corner_radius"/>
<stroke
android:width="5dp"
android:color="@android:color/transparent"/>
</shape>
</item>
<item android:top="7dp"
android:left="7dp"
android:right="7dp"
android:bottom="7dp">
<shape android:shape="rectangle" >
<solid android:color="#88ffffff"/>
<corners android:radius="@dimen/round_corner_radius"/>
</shape>
</item>
</layer-list>
activity.xml 내 문제를 해결
...
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/button"
android:background="@drawable/gradient"/>
...