设为首页 加入收藏

TOP

Android 使用shape制作drawable素材
2015-11-10 13:45:27 来源: 作者: 【 】 浏览:2
Tags:Android 使用 shape 制作 drawable 素材

首先看最终效果:


Android 使用shape制作drawable素材


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素材,代码很详细,就不贴源码了,按照以上步骤操作就可以做出最终效果,也可以做出自己想要的喜欢样式,欢迎大家一块学习交流~


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Android 实现RippleEffect水波纹.. 下一篇JavaScript中实现不加new关键字的..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: