




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
【移動應用開發技術】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. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025-2030年中國icu(監護病房)產業競爭格局及發展戰略研究報告
- 新鄉工程學院《自動化專業實驗Ⅰ》2023-2024學年第二學期期末試卷
- 新疆現代職業技術學院《財務信息系統分析與設計》2023-2024學年第二學期期末試卷
- 廣東省東莞市寮步鎮XX學校2024屆中考適應性考試數學試題含解析
- 2025年項目部安全培訓考試試題附完整答案(必刷)
- 2024-2025企業管理人員安全培訓考試試題及參考答案【達標題】
- 2024-2025工廠職工安全培訓考試試題答案達標題
- 2025年廠里廠里安全培訓考試試題(新)
- 2024-2025安全培訓考試試題及答案全套
- 2024-2025公司廠級員工安全培訓考試試題及參考答案【典型題】
- 電動卷簾門合同協議
- 北京市朝陽區區管企業年輕人才“培優”計劃招聘筆試真題2024
- 2025-2030中國太陽能電池板清潔系統行業市場發展趨勢與前景展望戰略研究報告
- 2025年廣東省深圳高級中學高中園高考數學三模試卷(含答案)
- 上海2025年上海市衛生健康技術評價中心上半年招聘16人筆試歷年參考題庫附帶答案詳解
- 建設分包合同保證金協議
- 2025年甘肅西北永新集團招聘11人筆試參考題庫附帶答案詳解
- 江蘇省鎮江市2024-2025學年下學期七年級數學期中試卷(原卷版+解析版)
- GB/T 45369-2025吸收性衛生用紙制品及原材料消臭效果評價方法
- 第一章+動量守恒定律+章末復習高二上學期物理人教版(2019)選擇性必修第一冊
- 學校崗位安全手冊指南
評論
0/150
提交評論