2
我有我設置8DP白色中風,這樣的圓形繪製組梯度:中風的Android
circleImage = (ImageView) rootView.findViewById(R.id.image);
circleImage.setOnClickListener(clickListener);
drawable = (GradientDrawable) circleImage.getBackground();
drawable.setStroke(8, getResources().getColor(R.color.colorWhite));
爲circleImage
的XML看起來是這樣的:
<ImageView
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_centerInParent="true"
android:id="@+id/image"
android:background="@drawable/roundcorner"
android:clickable="true"/>
我想要什麼現在要做的是改變drawable.setStroke
以包括像這樣的漸變色
我想最簡單的方法是用可繪製的XML寫東西,但我不太清楚如何實現這一點。
roundcorner.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<corners
android:topLeftRadius="100dp"
android:topRightRadius="100dp"
android:bottomLeftRadius="100dp"
android:bottomRightRadius="100dp"
/>
<padding
android:left="2dp"
android:top="2dp"
android:right="2dp"
android:bottom="2dp"
/>
<size
android:width="100dp"
android:height="100dp"
/>
</shape>
大,這就像一個魅力!十分感謝。 – Viktor