Android隨筆01

Dorcaszhu發表於2017-04-21

通訊機制

  1. 1G(Generation):僅限語音的蜂窩電話標準,只能在一定頻率上進行通話,容易被竊聽.代表是大哥大
  2. 2G:手機使用 PHS,GSM 或者 CDMA 這些十分成熟的標準,具有穩定的通話質量和合適的待機時間,支援彩信業務的 GPRS 和上網業務的 WAP 服務,以及各式各樣的 Java 程式等,代表小靈通
  3. 3G:將無線通訊與國際網際網路等多媒體通訊結合的新一代行動通訊系統
  4. 4G:該技術包括 TD-LTE 和 FDD-LTE 兩種制式.LTE是Long Term Evolution的縮寫.4G 是集 3G 與 WLAN 於一體,並能夠傳輸高質量視訊影象.4G 理論上可以達到 100Mbps 的下載速度

Android系統架構

應用程式層

該層不僅包括系統內建的應用也包括使用者自己安裝的應用

應用程式框架層

Android 系統中的每個應用都依賴於該框架提供的一系列服務和系統,其中包括:
1.活動管理器( Activity Manager) :用來管理應用程式生命週期並提供常用的導航回退功能
2. 豐富而又可擴充套件的檢視(Views):可以用來構建應用程式, 它包括列表(lists),網格(grids),文字框(textboxes),按鈕(buttons),甚至可嵌入的web 瀏覽器。
3. 內容提供器(Content Providers):使得應用程式可以訪問另一個應用程式的資料(如聯絡人資料庫), 或者共享它們自己的資料。
4. 資源管理器(Resource Manager):提供非程式碼資源的訪問,如本地字串,圖形,和佈局檔案( layoutfiles )。
5. 通知管理器(Notification Manager):使得應用程式可以在狀態列中顯示自定義的提示資訊。

系統執行庫層

該層主要分為Libaries程式庫和Android Runtime庫

Linux核心層

Android 的核心繫統服務依賴於 Linux 核心,如安全性,記憶體管理,程式管理,網路協議棧和驅動模型。Linux 核心也同時作為硬體和軟體棧之間的抽象層。

兩種虛擬機器的比較

Java程式設計師使用的是Java Virtual Machine(JVM),而我們Android使用的是Dalvik Virtual Machine(DVM);JVM執行的是.class檔案,而DVM執行的是.dex檔案;Dalvik 基於暫存器,而JVM 基於棧。

Android的五大布局

Android 有5 大布局,分別是RelativeLayout、LinearLayout、FrameLayout、AbsoluteLayout、TableLayout。不過前3 種佈局才是最常用的佈局,AbsoluteLayout 已經被Google 廢除,TableLayout 可以被GridView 替代,因此也很少用.

線性佈局LinearLayout

案例:
這裡寫圖片描述

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
    <EditText 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="number"/>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="MC" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="MR" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="MS" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="M+" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="M-" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="←" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="CE" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="C" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="+-" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="√" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="7" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="8" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="9" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="/" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="%" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="4" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="5" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="6" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="8" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="1/x" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <LinearLayout
            android:layout_width="0px"
            android:layout_height="wrap_content"
            android:layout_weight="4"
            android:orientation="vertical" >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal" >

                <Button
                    android:layout_width="0px"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:text="1" />

                <Button
                    android:layout_width="0px"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:text="2" />

                <Button
                    android:layout_width="0px"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:text="3" />

                <Button
                    android:layout_width="0px"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:text="-" />
            </LinearLayout>


            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal" >
                <Button
                    android:layout_width="0px"
                    android:layout_height="wrap_content"
                    android:layout_weight="2"
                    android:text="0" />

                <Button
                    android:layout_width="0px"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:text="." />

                <Button
                    android:layout_width="0px"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:text="+" />
            </LinearLayout>
        </LinearLayout>

        <Button
            android:layout_width="0px"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="=" />
    </LinearLayout>

</LinearLayout>

相關文章