Skip to content

Instantly share code, notes, and snippets.

@csdear
Created March 6, 2014 23:18
Show Gist options
  • Select an option

  • Save csdear/dd4b075c28cce1521054 to your computer and use it in GitHub Desktop.

Select an option

Save csdear/dd4b075c28cce1521054 to your computer and use it in GitHub Desktop.
Drawable : Canvas Simple shapes Style configuration of the textviews in main.xml each point to a shape xml file.
//main.xml contains the textviews whose drawable reference SQ shape xml files.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFCCCCCC"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@drawable/sq1"
android:gravity="center"
android:text="@string/text_literal"
android:textColor="#ff00ff00"
android:textSize="32sp"
android:textStyle="bold|italic"
android:typeface="normal" />
<TextView
android:id="@+id/imageView2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@drawable/sq2"
android:gravity="center"
android:text="@string/text_literal"
android:textColor="#FF00FFFF"
android:textSize="28sp"
android:textStyle="normal"
android:typeface="monospace"
android:layout_weight="1"/>
<TextView
android:id="@+id/imageView3"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@drawable/sq3"
android:gravity="center"
android:text="@string/text_literal"
android:textColor="#FFFFFF00"
android:textSize="24sp"
android:textStyle="bold"
android:typeface="serif"
android:layout_weight="1"/>
<TextView
android:id="@+id/imageView4"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@drawable/sq4"
android:ellipsize="middle"
android:gravity="center"
android:singleLine="true"
android:text="@string/long_text"
android:textColor="#FF0000FF"
android:textSize="20sp"
android:textStyle="italic"
android:typeface="sans"
android:layout_weight="1"/>
</LinearLayout>
=============================
//sq1.xml in the drawable res folder
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="@android:color/white" />
<stroke
android:width="3dp"
android:color="#FF000000" />
</shape>
=========================
//sq2.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#FFFFFF00" />
<stroke
android:width="25dp"
android:color="#FFFF0000" />
</shape>
================
//sq3
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#FF00FFFF" />
<stroke
android:width="8dp"
android:color="#FF0FF000" />
</shape>
===========================
//sq4.xml -- Notice the corners radius tag which allows you to make sexy round corners!!!
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#FFFFFFFF" />
<stroke
android:dashGap="2dp"
android:dashWidth="3dp"
android:width="5dp"
android:color="#FF000080" />
<corners android:radius="5dp" />
</shape>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment