http://www.dibbus.com/2011/02/gradient-buttons-for-android/에있는 자습서를 따르려고합니다. 그러나 예상 한 결과가 나타나지 않습니다. 모든 것이 잘 컴파일되지만, 실행하면 색상, 그라디언트 또는 테두리가없는 버튼이 생깁니다 (사실은 단추 텍스트 만 보입니다). 버튼 자체가 이벤트에 응답합니다.단추로 그릴 수있는 리소스가 표시되지 않습니다.
가능하면 많은 기기와 호환되도록 android : minSdkVersion = "3"을 사용하고 있습니다. 문제가 될 수 있습니까?
<TableRow>
<Button
android:id="@+id/button_calculate"
android:background="@drawable/copy_btn"
android:layout_column="1"
android:layout_span="2"
android:padding="5dp" />
</TableRow>
이것은 copy_btn.xml, 드로어 블 안에 위치 :
이 내 레이아웃 XML 파일의 일부입니다.
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" >
<shape>
<solid
android:color="#70c656" />
<stroke
android:width="1dp"
android:color="#53933f" />
<corners
android:radius="3dp" />
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
</shape>
</item>
<item>
<shape>
<gradient
android:startColor="#70c656"
android:endColor="#53933f"
android:angle="270" />
<stroke
android:width="1dp"
android:color="#53933f" />
<corners
android:radius="4dp" />
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
</shape>
</item>
</selector>
감사
android : layout_height = "wrap_content"android : layout_width = "wrap_content"를 버튼에 추가하십시오. –
이것은 작동하지 않습니다. 나는 이전과 같은 결과를 얻는다. 다른 제안들 ??. (부분) 내 새로운 XML은 \t \t \t \t <버튼 \t \t 안드로이드입니다 : ID = "@ + ID/button_calculate" \t \t 안드로이드 : 배경 = \t \t 안드로이드 "드로어 블/사진 copy_btn @"layout_column = " 1 " \t \t 로이드 : layout_span ="2 " \t \t 로이드 : layout_height ="wrap_content " \t \t 로이드 : layout_width ="wrap_content " ,972,\t android : padding = "5dp"/> \t \t –
Sandy