Graphics Layer Drawable

// Initialize some new ColorDrawable objects

android.graphics.drawable.ColorDrawable leftBorder = new android.graphics.drawable.ColorDrawable(Color.RED);
android.graphics.drawable.ColorDrawable topBorder = new android.graphics.drawable.ColorDrawable(Color.GREEN);
android.graphics.drawable.ColorDrawable rightBorder = new android.graphics.drawable.ColorDrawable(Color.BLUE);
android.graphics.drawable.ColorDrawable bottomBorder = new android.graphics.drawable.ColorDrawable(Color.YELLOW);
android.graphics.drawable.ColorDrawable background = new android.graphics.drawable.ColorDrawable(Color.WHITE);

 // Initialize an array of Drawable objects
android.graphics.drawable.Drawable[] layers = new android.graphics.drawable.Drawable[]{
          leftBorder, // Red color
          topBorder, // Green color
          rightBorder, // Blue color
          bottomBorder, // Yellow color
          background // White background
};

// Initialize a new LayerDrawable
android.graphics.drawable.LayerDrawable layerDrawable = new android.graphics.drawable.LayerDrawable(layers);

// Red layer padding, draw left border
layerDrawable.setLayerInset(0,0,0,15,0);

// Green layer padding, draw top border
layerDrawable.setLayerInset(1,15,0,0,15);

// Blue layer padding, draw right border
layerDrawable.setLayerInset(2,15,15,0,0);

// Yellow layer padding, draw bottom border
layerDrawable.setLayerInset(3,15,15,15,0);

// White layer, draw the background
layerDrawable.setLayerInset(4,15,15,15,15);

textview1.setBackground(layerDrawable);
textview1.setPadding(25,25,25,25);

Komentar

Cara pembuatan Apps paling Populer

Create Stopwatch App in Android using Sketchware

How to enable download in webview in Sketchware apps?

TextInputLayout in Sketchware

Create Stopwatch App in Android using Sketchware

How to integrate Admob Ads in Sketchware project using AIDE?

How to find and​ highlight a word in a text field in Sketchware?

Code for implementing Notifications in Sketchware

A Flash Light App in Sketchware

Create a Stopwatch App using Chronometer in Sketchware

Create app to save all passwords, protected using voice key