1
클립 레벨을 설정하려면 ClipDrawable
에 액세스해야합니다.ClipDrawable getDrawable() StateListDrawable을 반환합니다.
ClipDrawable drawable = (ClipDrawable) getResources().getDrawable(R.drawable.left_arrow);
내가 얻을 :이 같은 ClipDrawable
로 그릴 수 left_arrow
를 검색 할 때
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<rotate
android:fromDegrees="45"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="45">
<shape
android:shape="rectangle">
<size
android:width="250dp"
android:height="250dp"/>
<solid
android:color="#ffffff"/>
</shape>
</rotate>
</item>
</selector>
:
@drawable/left_arrow
:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<clip
xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/rotated_square"
android:clipOrientation="horizontal"
android:gravity="left" />
</item>
</selector>
@drawable/rotated_square
여기에 그릴 수있다 다음과 같은 오류가 난 n 개의 로그 캣은 :
Caused by: java.lang.ClassCastException: android.graphics.drawable.StateListDrawable cannot be cast to android.graphics.drawable.ClipDrawable
at com.vcapra1.pingpongscoreboard.MainActivity.onCreate(MainActivity.java:89)
왜 ClipDrawable
는 StateListDrawable로 반환되고있다?
사실은 첫 번째 요소가 "귀하의 드로어 블"인 statelistdrawable입니다. – rupps