首先看最终效果:

1、主布局XML文件
? ? android:layout_width="match_parent"
? ? android:layout_height="match_parent"
? ? android:orientation="vertical"
? ? android:padding="10dp" >
?
? ? ? ? ? ? android:layout_width="wrap_content"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:layout_marginBottom="20dp"
? ? ? ? android:background="@drawable/s1"
? ? ? ? android:padding="10dp"
? ? ? ? android:text="@string/s1"
? ? ? ? android:textColor="#fff"
? ? ? ? android:textSize="16sp" />
?
? ? ? ? ? ? android:layout_width="wrap_content"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:layout_marginBottom="20dp"
? ? ? ? android:background="@drawable/s2"
? ? ? ? android:padding="10dp"
? ? ? ? android:text="@string/s2"
? ? ? ? android:textColor="#ff9800"
? ? ? ? android:textSize="16sp" />
?
? ? ? ? ? ? android:layout_width="50dp"
? ? ? ? android:layout_height="50dp"
? ? ? ? android:layout_marginBottom="20dp"
? ? ? ? android:background="@drawable/s3"
? ? ? ? android:padding="10dp"
? ? ? ? android:scaleType="fitXY"
? ? ? ? android:src="@drawable/ic_launcher" />
?
? ? ? ? ? ? android:layout_width="wrap_content"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:layout_marginBottom="20dp"
? ? ? ? android:background="@drawable/s4"
? ? ? ? android:padding="5dp"
? ? ? ? android:text="@string/s4"
? ? ? ? android:textColor="#fff"
? ? ? ? android:textSize="16sp" />
?
? ? ? ? ? ? android:layout_width="wrap_content"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:layout_marginBottom="20dp"
? ? ? ? android:background="@drawable/s5"
? ? ? ? android:padding="5dp"
? ? ? ? android:text="@string/s5"
? ? ? ? android:textColor="#00bcd4"
? ? ? ? android:textSize="16sp" />
?
? ? ? ? ? ? android:layout_width="wrap_content"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:layout_marginBottom="20dp"
? ? ? ? android:background="@drawable/s6"
? ? ? ? android:padding="5dp"
? ? ? ? android:text="@string/s6"
? ? ? ? android:textColor="#fff"
? ? ? ? android:textSize="16sp" />
?
2、shape文件
? 1)s1.xml
? ?
? ?
? 2)s2.xml?
? ?
? ?
? ?
? 3)s3.xml?
?
? ?
? ? ?
? ?
?
?
? ?
? ? ?
? ?
?
?
? ?
? ? ?
? ?
?
? 4)s4.xml
?
? ?
? ? ?
? ? ?
? ?
?
?
? ?
? ? ?
? ? ?
? ?
?
?
? ?
? ? ?
? ? ?
? ?
?
? 5)s5.xml
?
? ?
? ? ?
? ? ?
? ? ?
? ?
?
?
? ?
? ? ?
? ? ?
? ? ?
? ?
?
?
? ?
? ? ?
? ? ?
? ? ?
? ?
?
? 6)s6.xml
? ?
? ?
? ? ?
? ? ? ?
? ? ? ? ?
? ? ? ? ?
? ? ? ?
? ? ?
? ?
?
?
? ?
? ? ?
? ? ? ?
? ? ? ? ?
? ? ? ? ?
? ? ? ?
? ? ?
? ?
?
?
? ?
? ? ?
? ? ? ?
? ? ? ? ?
? ? ? ? ?
? ? ? ?
? ? ?
? ? ?
? ? ? ?
? ? ? ? ?
? ? ? ? ?
? ? ? ?
? ? ?
? ?
?
3、String.xml
?
? ? shape制作drawable素材
? ? Settings
? ? Hello world!
? ? 我是第一行
? ? 我是第二行
? ? 我是第三行
? ? 我是第四行
? ? 我是第五行
? ? 我是第六行
?
4、主界面Activity代码
package com.sunny.shape;
?
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.Window;
?
public class MainActivity extends Activity {
?
? ? @Override
? ? protected void onCreate(Bundle savedInstanceState) {
? ? ? ? super.onCreate(savedInstanceState);
? ? ? ? requestWindowFeature(Window.FEATURE_NO_TITLE);
? ? ? ? setContentView(R.layout.activity_main);
? ? }
}
? ? 以上就是使用shape制作drawable素材,代码很详细,就不贴源码了,按照以上步骤操作就可以做出最终效果,也可以做出自己想要的喜欢样式,欢迎大家一块学习交流~