android學習筆記
故事是這樣的,因公司目前一個移動體征檢測產品需要聯網。部門只有一個移動開發小伙,其他都是C#開發人員??蛻羰菭敯?!正當我無人可用、一籌莫展的時候,這小伙竟然叫我這個安卓新手給他搬磚。沒辦法,我這老家伙也硬著頭皮上了。小伙帶著我這個拖油瓶一路走來,寫一點自己項目中的認知
1、android studio中添加圖片名稱是不能有大寫字符,否則編譯報錯
2、以XML方式書寫TabLayout時,代碼如下。需要注意的地方如下圖
<TabHost
android:id="@+id/main_tabHost"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<!-- TabWidget的id屬性必須為 @android:id/tabs -->
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:orientation="horizontal" />
<!-- FrameLayout的id屬性必須為 @android:id/tabcontent -->
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0" >
<ImageView
android:id="@+id/tab1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/sample"
/>
<ImageView
android:id="@+id/tab2"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:src="@drawable/new_patient"
/>
<ImageView
android:id="@+id/tab3"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:src="@drawable/cases"
/>
<ImageView
android:id="@+id/tab4"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:src="@drawable/config1"
/>
</FrameLayout>
</LinearLayout>
</TabHost>
未完繼續.........
浙公網安備 33010602011771號