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

TextInputLayout in Sketchware

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

A Flash Light App in Sketchware

How to enable download in webview in Sketchware apps?

Intent - Open File By Type

Code for implementing Notifications in Sketchware

How to share an image from Drawable folder?

ActionBar back button

Animation Transtition Animation