Repository: NativeScript/NativeScript
File: packages/core/ui/slider/index.android.ts (TypeScript)

Code before:
		if (value instanceof Color) {
			AndroidHelper.setDrawableColor(value.android, drawable);
		} else {
			AndroidHelper.clearDrawableColor(drawable);
		}
	}

	[backgroundColorProperty.getDefault](): number {
		return -1;
	}
	[backgroundColorProperty.setNative](value: number | Color) {
		const drawable = this.nativeViewProtected.getProgressDrawable();
		if (value instanceof Color) {
			AndroidHelper.setDrawableColor(value.android, drawable);
		} else {
			AndroidHelper.clearDrawableColor(drawable);
		}
	}

	[backgroundInternalProperty.getDefault](): Background {
		return null;
	}
	[backgroundInternalProperty.setNative](value: Background) {
		if (value && value.image instanceof LinearGradient) {
			this._applyGradientToTrack(value.image);
		}
	}

	private _applyGradientToTrack(gradient: LinearGradient): void {
		const nativeView = this.nativeViewProtected;
		if (!nativeView) {
			return;
		}

		// Create colors array from gradient stops
		const colors = Array.create('int', gradient.colorStops.length);
		const positions = Array.create('float', gradient.colorStops.length);
		let hasPositions = false;

		gradient.colorStops.forEach((stop, index) => {
			colors[index] = stop.color.android;
			if (stop.offset) {
				positions[index] = stop.offset.value;
				hasPositions = true;
			} else {
				// Default evenly distributed positions
				positions[index] = index / (gradient.colorStops.length - 1);
			}
		});

		// Calculate gradient direction based on angle

Review comment (suggestion):
Actually unfortunately @omairqazi29 it does not work on Android if able to check this.
<img width="355" height="817" alt="Screenshot 2025-12-26 at 3 41 28 PM" src="https://github.com/user-attachments/assets/ed72f9a7-43e8-466a-bf3c-9791d706dd81" />


Code after:
		if (value instanceof Color) {
			AndroidHelper.setDrawableColor(value.android, drawable);
		} else {
			AndroidHelper.clearDrawableColor(drawable);
		}
	}

	[backgroundColorProperty.getDefault](): number {
		return -1;
	}
	[backgroundColorProperty.setNative](value: number | Color) {
		const drawable = this.nativeViewProtected.getProgressDrawable();
		if (value instanceof Color) {
			AndroidHelper.setDrawableColor(value.android, drawable);
		} else {
			AndroidHelper.clearDrawableColor(drawable);
		}
	}

	[backgroundInternalProperty.getDefault](): Background {
		return null;
	}
	[backgroundInternalProperty.setNative](value: Background) {
		if (value && value.image instanceof LinearGradient) {
			this._applyGradientToTrack(value.image);
		}
	}

	private _applyGradientToTrack(gradient: LinearGradient): void {
		const nativeView = this.nativeViewProtected;
		if (!nativeView) {
			return;
		}

		// Get dimensions
		const density = nativeView.getContext().getResources().getDisplayMetrics().density;
		const width = nativeView.getWidth() || 1000;
		const trackHeight = Math.round(3 * density); // 3dp track height to match iOS
		const cornerRadius = trackHeight / 2;

		// Create colors array from gradient stops
		const colors = Array.create('int', gradient.colorStops.length);
		gradient.colorStops.forEach((stop, index) => {
			colors[index] = stop.color.android;
		});

		// Create semi-transparent colors for background
		const bgColors = Array.create('int', gradient.colorStops.length);
		gradient.colorStops.forEach((stop, index) => {
			const color = stop.color;
			const alpha = Math.round(color.a * 0.3);