Platform-specific TypeScript declarations for NativeScript for accessing native objects
84
Create a reusable card component for a NativeScript Android application that implements Material Design styling using modern Android UI libraries.
Your implementation should create a custom card view that:
The component should be implemented as a TypeScript class that wraps the appropriate native Android view components. The implementation should properly initialize native views, configure Material Design properties, and handle view lifecycle.
@generates
/**
* A Material Design card component for NativeScript Android applications.
* Wraps native Android views to provide elevated, styled containers.
*/
export class MaterialCard {
/**
* Creates a new MaterialCard instance with the specified configuration.
* @param config - Configuration options for the card
*/
constructor(config: CardConfig);
/**
* Gets the underlying native Android view.
* @returns The native card view instance
*/
getNativeView(): any;
/**
* Sets the corner radius of the card.
* @param radius - Corner radius in density-independent pixels
*/
setCornerRadius(radius: number): void;
/**
* Sets the elevation of the card.
* @param elevation - Elevation in density-independent pixels
*/
setElevation(elevation: number): void;
/**
* Sets the background color of the card.
* @param color - Color value as Android color integer
*/
setCardBackgroundColor(color: number): void;
/**
* Adds a child view to the card.
* @param view - The native view to add as content
*/
addContentView(view: any): void;
}
/**
* Configuration options for MaterialCard
*/
export interface CardConfig {
cornerRadius?: number;
elevation?: number;
backgroundColor?: number;
}Provides TypeScript type definitions for accessing native Android APIs and AndroidX libraries.
Install with Tessl CLI
npx tessl i tessl/npm-tns-platform-declarationsevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10