歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Android開發:抄襲微博布局總結

Android開發:抄襲微博布局總結

日期:2017/3/1 10:45:37   编辑:Linux編程

別人的好的東西,就應該拿過來借鑒,並改進,我想這就是拿來主義

我畫圖不好,其實我很想用畫圖的方式來說明一切,因為通俗簡單的就是最好的

首先是思維導圖...這個思維導圖,因為只能看界面,得不到源代碼,所以通過畫圖的方式來分析界面以及功能

這是主頁的xml ,相信明眼人一看就知道,這是全屏幕適配的. 來自沈大海的微博教學以及 農民伯伯的 博客分析新浪官方微博布局

粉紅色分為固定像素的頂部條以及底部Tab菜單

頂部只有RelativeLayout構成,可以添加標題,各種小提示..

底部則為Tab選項卡,為不同的Activity切換

然後中間部分整體為黃色部分,也就是動態改變刷新各種數據的Layout

然後又按比例細分為 [藍色紅色] 以及 [淺藍色],他們占相應比例充滿父類

深藍和紅色為同一Layout,紅色寬度為fill_parent,高度為wrap_content,

為每個不同的Activity添加進不同的頭部item奠定自由的基礎

而深藍則高度寬度都為fill_parent,與紅色layout一起充滿父類,

藍色可以添加listView或者添加GridView來現實微博列表或者是用戶列表,用過pad版的微博的人應該都會知道

正題邏輯分為BossActivity 掌管所有顯示layout,然後的Activity有搜索,我的主頁,信息,@,....

它們都不需要任何布局,只需要合理的調用生命周期,來刷新數據往Boss裡面的深藍色部分刷新

紅色部分則每個子Activity<搜索,我的主頁,信息,@,...>都是對應不一樣的 可以用LayoutInflater來加載...

淺藍色部分,則為衍生的三個Activity的裝載layout 哪三個,上圖很清晰 分別是微博正文,用戶信息,以及話題詳情

那點擊深藍色部分的item時候該響應加載哪個Activity?這就有你來指揮了.

難點在於...用戶信息Activity還要再看用戶信息,再看某個用戶信息,再看微博正文,再看某用戶的微博...

這三個Activity都是可以復用的.思維導圖也可以明顯地看出有一個循環

這個想法是由我定下的,但是我想寫代碼過程中 肯定會遇到種種細節上的困難...

還有這樣的想法,如果有人有好的建議或者意見的話 一定要提出來

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <TabHost
  3. xmlns:Android="http://schemas.android.com/apk/res/android"
  4. android:orientation="vertical"
  5. android:gravity="center"
  6. android:layout_width="fill_parent"
  7. android:layout_height="fill_parent"
  8. android:id="@+id/@android:id/tabhost"
  9. android:background="@drawable/myweibo_boss_bg">
  10. <RelativeLayout
  11. android:layout_width="fill_parent"
  12. android:layout_height="fill_parent"
  13. android:orientation="vertical">
  14. <!-- top橫條 -->
  15. <RelativeLayout
  16. android:background="@drawable/top3"
  17. android:layout_width="fill_parent"
  18. android:layout_height="41dip"
  19. android:id="@+id/layout_weibo_boss_top"></RelativeLayout>
  20. <RelativeLayout
  21. android:layout_centerInParent="true"
  22. android:layout_below="@+id/layout_weibo_boss_top"
  23. android:layout_above="@+id/layout_weibo_boss_bottom"
  24. android:layout_width="fill_parent"
  25. android:layout_height="fill_parent"
  26. android:id="@+id/layout_weibo_boss_middle_msg"></RelativeLayout>
  27. <LinearLayout
  28. android:layout_below="@+id/layout_weibo_boss_top"
  29. android:layout_above="@+id/layout_weibo_boss_bottom"
  30. android:id="@+id/layout_weibo_boss_middle"
  31. android:orientation="horizontal"
  32. android:layout_width="fill_parent"
  33. android:layout_height="fill_parent">
  34. <LinearLayout
  35. android:layout_weight="1.0"
  36. android:orientation="vertical"
  37. android:layout_width="fill_parent"
  38. android:layout_height="fill_parent"
  39. android:id="@+id/weiboBoss_LeftLayout"
  40. android:background="@drawable/weibo_list_bg">
  41. <!-- listView頭上那堆View -->
  42. <RelativeLayout
  43. android:background="@drawable/weibo_boss_topitems_bg"
  44. android:layout_width="fill_parent"
  45. android:layout_height="wrap_content"
  46. android:id="@+id/topItem_of_weiboBoss_LeftLayout">
  47. </RelativeLayout>
  48. <!-- ListView或者GridView的layout -->
  49. <RelativeLayout
  50. android:layout_width="fill_parent"
  51. android:layout_height="fill_parent"
  52. android:id="@+id/list_of_weiboBoss_LeftLayout">
  53. </RelativeLayout>
  54. </LinearLayout>
  55. <!-- Boss右邊的詳情layout,可以是微博詳情或者是用戶詳情 -->
  56. <RelativeLayout
  57. android:layout_weight="1.0"
  58. android:layout_width="fill_parent"
  59. android:layout_height="fill_parent"
  60. android:id="@+id/weiboBoss_RightLayout"></RelativeLayout>
  61. </LinearLayout>
  62. <FrameLayout
  63. android:layout_width="fill_parent"
  64. android:layout_height="0.0dip"
  65. android:layout_weight="1.0"
  66. android:id="@android:id/tabcontent">
  67. </FrameLayout>
  68. <TabWidget
  69. android:layout_width="fill_parent"
  70. android:layout_height="0.0dip"
  71. android:layout_weight="0.0"
  72. android:visibility="gone"
  73. android:id="@android:id/tabs"></TabWidget>
  74. <!-- 底部橫條以及RadioButton -->
  75. <RelativeLayout
  76. android:layout_alignParentBottom="true"
  77. android:layout_width="fill_parent"
  78. android:layout_height="57dip"
  79. android:background="@drawable/formlist_bottom_btn"
  80. android:id="@+id/layout_weibo_boss_bottom">
  81. <RadioGroup
  82. android:layout_width="wrap_content"
  83. android:layout_height="57dip"
  84. android:orientation="horizontal"
  85. android:gravity="center_vertical"
  86. android:layout_gravity="bottom"
  87. android:id="@+id/boss_radio">
  88. <RadioButton
  89. android:drawableTop="@drawable/radio_newstyle_boss_home"
  90. android:checked="true"
  91. android:id="@+id/radio_button0"
  92. android:layout_marginTop="2.0dip"
  93. style="@style/boss_tab_bottom">
  94. </RadioButton>
  95. <RadioButton
  96. android:drawableTop="@drawable/radio_newstyle_boss_search"
  97. android:id="@+id/radio_button1"
  98. android:layout_marginTop="2.0dip"
  99. style="@style/boss_tab_bottom" />
  100. <RadioButton
  101. android:drawableTop="@drawable/radio_newstyle_boss_myweibo"
  102. android:id="@+id/radio_button2"
  103. android:layout_marginTop="2.0dip"
  104. style="@style/boss_tab_bottom" />
  105. <RadioButton
  106. android:drawableTop="@drawable/radio_newstyle_boss_reply"
  107. android:id="@+id/radio_button3"
  108. android:layout_marginTop="2.0dip"
  109. style="@style/boss_tab_bottom" />
  110. <RadioButton
  111. android:drawableTop="@drawable/radio_newstyle_boss_atme"
  112. android:id="@+id/radio_button4"
  113. android:layout_marginTop="2.0dip"
  114. style="@style/boss_tab_bottom" />
  115. <RadioButton
  116. android:drawableTop="@drawable/radio_newstyle_boss_neweibo"
  117. android:id="@+id/radio_button5"
  118. android:layout_marginTop="2.0dip"
  119. style="@style/boss_tab_bottom" />
  120. </RadioGroup>
  121. </RelativeLayout>
  122. </RelativeLayout>
  123. </TabHost>

後面再記錄每個小節出現的問題和解決方案。

Android新浪微博-項目整理總結 一[創建新項目] http://www.linuxidc.com/Linux/2011-12/50137.htm

Copyright © Linux教程網 All Rights Reserved