【移動應用開發技術】Android 使用shape制作drawable素材_第1頁
【移動應用開發技術】Android 使用shape制作drawable素材_第2頁
【移動應用開發技術】Android 使用shape制作drawable素材_第3頁
【移動應用開發技術】Android 使用shape制作drawable素材_第4頁
【移動應用開發技術】Android 使用shape制作drawable素材_第5頁
已閱讀5頁,還剩5頁未讀 繼續免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

【移動應用開發技術】Android使用shape制作drawable素材

Android開發中,資源文件中會有大量的圖片素材文件,這樣會額外增加APP的大小,有時面對對APP大小有限制的,那就要考慮盡可能的對圖片進行壓縮處理或者減少資源文件中圖片的數量,那么減少了資源素材文件,我們如何滿足應用對圖形的豐富要求呢?我們可以使用shape繪制的,有很多優點。從而滿足我們的要求,下面是我整理的一些素材:

首先看最終效果:1、主布局XML文件<LinearLayout

xmlns:android="/apk/res/android"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical"

android:padding="10dp"

>

<TextView

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"

/>

<TextView

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"

/>

<ImageButton

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"

/>

<Button

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"

/>

<Button

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"

/>

<Button

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"

/>

</LinearLayout>2、shape文件

1)s1.xml<?xml

version="1.0"

encoding="utf-8"?>

<shape

xmlns:android="/apk/res/android"

>

<solid

android:color="#23C7B2"

/>

<corners

android:radius="8dp"

/>

</shape>

2)s2.xml

<?xml

version="1.0"

encoding="utf-8"?>

<shape

xmlns:android="/apk/res/android"

>

<solid

android:color="#00000000"

/>

<corners

android:radius="8dp"

/>

<stroke

android:width="1dp"

android:color="#ff9800"

/>

</shape>

3)s3.xml

<selector

xmlns:android="/apk/res/android">

<item

android:state_pressed="true">

<shape

android:shape="oval">

<solid

android:color="#42A0DB"

/>

</shape>

</item>

<item

android:state_focused="true">

<shape

android:shape="oval">

<solid

android:color="#42A0DB"

/>

</shape>

</item>

<item>

<shape

android:shape="oval">

<solid

android:color="#42A0DB"

/>

</shape>

</item>

</selector>

4)s4.xml<selector

xmlns:android="/apk/res/android">

<item

android:state_pressed="true">

<shape>

<solid

android:color="#7F79B5"

/>

<corners

android:radius="8dp"

/>

</shape>

</item>

<item

android:state_focused="true">

<shape>

<solid

android:color="#7F79B5"

/>

<corners

android:radius="8dp"

/>

</shape>

</item>

<item>

<shape>

<solid

android:color="#7F79B8"

/>

<corners

android:radius="8dp"

/>

</shape>

</item>

</selector>

5)s5.xml<selector

xmlns:android="/apk/res/android">

<item

android:state_pressed="true">

<shape>

<solid

android:color="#e3e3e3"

/>

<corners

android:radius="8dp"

/>

<stroke

android:width="1dp"

android:color="#00bcd4"

/>

</shape>

</item>

<item

android:state_focused="true">

<shape>

<solid

android:color="#e3e3e3"

/>

<corners

android:radius="8dp"

/>

<stroke

android:width="1dp"

android:color="#00bcd4"

/>

</shape>

</item>

<item>

<shape>

<solid

android:color="#00000000"

/>

<corners

android:radius="8dp"

/>

<stroke

android:width="1dp"

android:color="#00bcd4"

/>

</shape>

</item>

</selector>

6)s6.xml<?xml

version="1.0"

encoding="utf-8"?>

<selector

xmlns:android="/apk/res/android"

>

<item

android:state_pressed="true">

<layer-list>

<item

android:top="3dp">

<shape>

<solid

android:color="#00bcd4"

/>

<corners

android:radius="8dp"

/>

</shape>

</item>

</layer-list>

</item>

<item

android:state_focused="true">

<layer-list>

<item

android:top="3dp">

<shape>

<solid

android:color="#00bcd4"

/>

<corners

android:radius="8dp"

/>

</shape>

</item>

</layer-list>

</item>

<item>

<layer-list>

<item>

<shape>

<solid

android:color="#dddddd"

/>

<corners

android:radius="8dp"/>

</shape>

</item>

<item

android:bottom="3dp">

<shape>

<solid

android:color="#00bcd4"

/>

<corners

android:radius="8dp"/>

</shape>

</item>

</layer-list>

</item>

</selector>3、String.xml<?xml

version="1.0"

encoding="utf-8"?>

<resources>

<string

name="app_name">shape制作drawable素材</string>

<string

name="action_settings">Settings</string>

<string

name="hello_world">Hello

world!</string>

<string

name="s1">我是第一行</string>

<string

name="s2">我是第二行</string>

<string

na

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論