I wanted to generate horizontal text color gradient for my AppCompatButton. I was able to accomplish the vertical text color gradient by
val signInBtn = view.findViewById<AppCompatButton>(R.id.btn_sign_in)
val textShader = LinearGradient(0f, 0f, 0f, signInBtn.textSize,
ContextCompat.getColor(context, R.color.gradient_start),
ContextCompat.getColor(context, R.color.gradient_end), TileMode.CLAMP)
signInBtn.paint.shader = textShader
I've tried changing the x2 values, but nothing seems to work. Any help would be appreciated.
here is my button xml layout
<android.support.v7.widget.AppCompatButton
android:id="@+id/btn_sign_in"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/big"
android:layout_marginStart="@dimen/big"
android:layout_marginTop="@dimen/big"
android:background="@color/white"
android:text="@string/sign_in"
android:textAllCaps="false"
android:fadingEdge="horizontal"
android:scrollHorizontally="true"
android:textColor="@color/white"/>