9
Android: Shapes 1

Android: Shapes

  • Upload
    teige

  • View
    19

  • Download
    1

Embed Size (px)

DESCRIPTION

Android: Shapes. Right click on res/drawable select New/Android XML. Supply a filename (small letters) Choose shape as the root element. Click Finish. Enter a gradient element, supply its startColor and endColor attributes. - PowerPoint PPT Presentation

Citation preview

Page 1: Android: Shapes

Android: Shapes

1

Page 2: Android: Shapes

Right click on res/drawable select New/Android XML

2

Page 3: Android: Shapes

Supply a filename (small letters) Choose shape as the root element. Click Finish.

3

Page 4: Android: Shapes

Enter a gradient element, supply its startColor and endColor attributes.

4

<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" > <gradient android:startColor="#cccccc" android:endColor="#333333" /></shape>

Page 5: Android: Shapes

In your layout add a background attribute and set its value to the xml file you just placed in drawable

5

Page 6: Android: Shapes

The result in Graphical Layout mode.

6

Page 7: Android: Shapes

Add another Android XML file to drawable

7

<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval"> <solid android:color="#3399ff" /></shape>

Page 8: Android: Shapes

Set the TextView’s android:background attribute to &srawable/my_circle

8

Page 9: Android: Shapes

Result of setting TextView’s background to shape (oval)

9