당김 변경 색상으로 회전 :안드로이드 형태의 XML은이 삼각형 모양의 XML입니다 프로그래밍
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/shape_id">
<rotate
android:fromDegrees="45"
android:toDegrees="45"
android:pivotX="-40%"
android:pivotY="87%" >
<shape android:shape="rectangle" >
<stroke android:width="10dp"/>
</shape>
</rotate>
</item>
</layer-list>
을 그리고 이것은 텍스트 뷰
<TextView
android:id="@+id/headlineSelect_TXT2"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_weight="1"
android:background="@drawable/category_triangle_shape1"
android:visibility="invisible" />
의 배경입니다 그리고 프로그래밍 모양의 색상을 변경하려면 . 나는 이것을 시도했지만 널 포인터 예외가 발생했다.
LayerDrawable bgDrawable = (LayerDrawable) getActivity()
.getResources()
.getDrawable(R.drawable.category_triangle_shape1);
final GradientDrawable shape = (GradientDrawable) bgDrawable
.findDrawableByLayerId(R.id.shape_id);
shape.setStroke(10,Color.GREEN);
어떻게 할 수 있습니까? 도와 주셔서 감사합니다.
감사 답변을하지만이 사각형 모양입니다. 삼각형이 필요해. – skhizein