本軟體設定用戶第一個接觸到的功能就是頁面載入等待功能,這個功能對使用者來說就是一個持續1、2秒鐘的等待頁面,在用戶等待的同時程式做一些必要的檢查以及數據準備工作,載入頁面分為UI篇和功能篇,從表及里首先是UI的實現,一個軟體除功能之外還得有一個光鮮的外表也是非常重要的,儘管本人設計水平一般但是還是親
本軟體設定用戶第一個接觸到的功能就是頁面載入等待功能,這個功能對使用者來說就是一個持續1、2秒鐘的等待頁面,在用戶等待的同時程式做一些必要的檢查以及數據準備工作,載入頁面分為UI篇和功能篇,從表及里首先是UI的實現,一個軟體除功能之外還得有一個光鮮的外表也是非常重要的,儘管本人設計水平一般但是還是親自操刀用ps先做了一下設計效果圖如下:
<ignore_js_op>![](http://www.apkbus.com/data/attachment/forum/201104/21/141659dzlslczlfpclpsll.png)
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/layout"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- <ImageView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:src="@drawable/ver"
- android:layout_marginTop="15dip"
- android:layout_marginLeft="15dip">
- </ImageView>
- <RelativeLayout
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- <ImageView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:src="@drawable/logo"
- android:layout_centerInParent="true">
- </ImageView>
- <ImageView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:src="@drawable/dev"
- android:layout_alignParentBottom="true"
- android:layout_alignParentRight="true"
- android:layout_marginRight="5dip"
- android:layout_marginBottom="35dip">
- </ImageView>
- </RelativeLayout>
- </LinearLayout>
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- }
- //獲取屏幕方向
- public static int ScreenOrient(Activity activity)
- {
- int orient = activity.getRequestedOrientation();
- if(orient != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE && orient != ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
- //寬>高為橫屏,反正為豎屏
- WindowManager windowManager = activity.getWindowManager();
- Display display = windowManager.getDefaultDisplay();
- int screenWidth = display.getWidth();
- int screenHeight = display.getHeight();
- orient = screenWidth < screenHeight ? ActivityInfo.SCREEN_ORIENTATION_PORTRAIT : ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
- }
- return orient;
- }
- public static void AutoBackground(Activity activity,View view,int Background_v, int Background_h)
- {
- int orient=ScreenOrient(activity);
- if (orient == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) { //縱向
- view.setBackgroundResource(Background_v);
- }else{ //橫向
- view.setBackgroundResource(Background_h);
- }
- }
- LinearLayout layout=(LinearLayout)findViewById(R.id.layout);
- //背景自動適應
- AndroidHelper.AutoBackground(this, layout, R.drawable.bg_v, R.drawable.bg_h);
到此完成了載入頁面的UI部分的實現,測試運行模擬器中查看效果,基本上跟最上面的設計效果圖相符,測試效果圖如下: <ignore_js_op>
![](http://www.apkbus.com/data/attachment/forum/201104/21/141706t8l78kztx9t8b3qt.png)
<ignore_js_op>
![](http://www.apkbus.com/data/attachment/forum/201104/21/141654h4cc6444d0dz4440.png)
問啊-定製化IT教育平臺,牛人一對一服務,有問必答,開發編程社交頭條 官方網站:www.wenaaa.com
QQ群290551701 聚集很多互聯網精英,技術總監,架構師,項目經理!開源技術研究,歡迎業內人士,大牛及新手有志於從事IT行業人員進入!