編輯:進階開發
延續前一篇的 Android UI 佈局講解,以下是一段 LinearLayout 的 XML 程式碼片段,示範了 EditText、TextView 與 Button 在橫向 LinearLayout 中的排布與 layout_weight 權重分配:
ditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:id="@+id/edittext" /> <LinearLayout android:id="@+id/LinearLayout01" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView android:text="text1" android:id="@+id/TextView01" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <Button android:text="Button01" android:id="@+id/Button01" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" /> <TextView android:text="text2" android:id="@+id/TextView02" android:layout_width="wrap_content" android:layout_
Android 裝置與介面選項:用感測器打造環境監控應用
Android 是一個面向應用開發的富平台,擁有大量具吸引力的 UI 元素與資料管理功能,同時也提供一組豐富的介面選項。本文說明如何搭配各種感測器來監控你的環境,並從程式
十分鐘入門 Android 四大組件與 Intent 匹配機制
Android 基本組件在日常生活中的應用其實相當普遍,但要用得順手,得先弄清楚它是什麼、由哪些部分組成。 Intent 的六項基本資訊 Intent 包含六類資訊:目
Android 音訊播放雙雄:SoundPool 與 MediaPlayer 完整用法
Android 平台上播放音訊,最常用的是兩個類別:SoundPool 與 MediaPlayer。選錯工具,會直接反映在延遲和記憶體佔用上。 SoundPool 適合短
Activity 的四種啟動模式(1):先弄懂生命週期
建議先讀過下面兩篇,才能比較好地理解啟動模式: Android 的行程與執行緒模型(cnblogs.com/ghj1976)——其中對「Android 單執行緒模型」的描