Android的官方Twitter客戶端有一個不錯的工具欄,當你點擊一條消息,可以讓你轉推,回覆等。我該如何重新創建一個工具欄?如何將工具欄添加到Android活動?
回答
對於LinearLayout方法,代碼很簡單,只需添加一些權重並隨時查找所需內容即可。這給你方法的一個粗略的想法:
<EditText android:text="Example Layout"
android:layout_width="match_parent"
android:id="@+id/editText"
android:layout_height="wrap_content"
android:layout_weight="0.95"></EditText>
<LinearLayout
android:layout_width="fill_parent"
android:orientation="horizontal"
android:weightSum="1.0"
android:padding="1px"
android:layout_height="wrap_content"
android:layout_weight="0.05">
<ImageButton android:id="@+id/testButton1"
android:layout_weight="0.2"
android:background="@drawable/btn"
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
<ImageButton android:id="@+id/testButton2"
android:layout_weight="0.2"
android:background="@drawable/btn"
android:layout_height="wrap_content"
android:layout_width="wrap_content" />
<ImageButton android:id="@+id/testButton3"
android:layout_weight="0.2"
android:background="@drawable/btn"
android:layout_height="wrap_content"
android:layout_width="wrap_content" />
<ImageButton android:id="@+id/testButton4"
android:layout_weight="0.2"
android:background="@drawable/btn"
android:layout_height="wrap_content"
android:layout_width="wrap_content" />
<ImageButton android:id="@+id/testButton5"
android:layout_weight="0.2"
android:background="@drawable/btn"
android:layout_height="wrap_content"
android:layout_width="wrap_content" />
</LinearLayout>
和結果是這樣的:http://i.stack.imgur.com/bShgb.png
你也可以很樂意與動作條爲好,只是看API要求:http://developer.android.com/guide/topics/ui/actionbar.html
他知道什麼是工具欄,什麼是他要求的實現。順便說一句http://www.androidpatterns.com/uap_pattern/toolbar – aromero 2011-04-26 02:21:47
這裏是Twitter工具欄的屏幕截圖http://www.wirefresh.com/images/twitter-android-update-1.jpg – 2011-04-26 02:23:34
至少有2個不同的我知道的工具欄的意見,所以謝謝你的截圖。你有沒有試過一個簡單的水平LinearLayout放置它的按鈕? – Jack 2011-04-26 02:37:56
我們稱之爲QuickAction:
查找更多關於如何在這裏實現它:http://www.londatiga.net/it/how-to-create-quickaction-dialog-in-android/
很好的實施,謝謝! – 2012-05-16 06:33:54
- 1. 如何將CheckBox添加到工具欄?
- 2. 如何將textField添加到工具欄
- 3. 如何在工具欄下添加工具欄 - android
- 4. 如何將窗口按鈕添加到Android工具欄?
- 5. Android - 如何將ID添加到工具欄後退按鈕?
- 6. android在同一個活動中添加兩個工具欄?
- 7. 如何添加工具欄
- 8. 如何將後退按鈕添加到操作欄/工具欄
- 9. 自動添加工具欄
- 10. 將工具欄添加到部分
- 11. 將操作添加到Eclipse工具欄
- 12. 將此事件添加到工具欄
- 13. 將工具欄添加到UITableViewController
- 14. 將按鈕添加到工具欄
- 15. 將工具欄添加到視圖
- 16. 如何將工具欄添加到Visual Studio加載項?
- 17. 所有活動中的Android工具欄
- 18. 如何在Android Studio中將Android設備監視器添加到主工具欄?
- 19. 在Android中添加不可滑動的Tab到工具欄
- 20. Android將按鈕以編程方式添加到工具欄
- 21. 以編程方式將工具欄添加到Android中的RelativeView
- 22. 將標籤添加到Android 5.0工具欄?
- 23. 如何默認小工具添加到自定義動態欄
- 24. 如何在PyQt4中添加一個浮動工具欄到QFrame?
- 25. 如何將微調器添加到活動的標題欄?
- 26. 如何將操作欄項添加到第二個活動
- 27. 如何將「活動」類添加到導航欄?
- 28. 如何將後退箭頭添加到工具欄?
- 29. 如何將barButtonItem添加到工具欄中
- 30. 如何將間隔器添加到Eclipse RCP工具欄?
是在消息的詳細視圖(一個在左在你的屏幕截圖)顯示的工具欄似乎是一個一個的LinearLayout屏幕底部佈滿了一堆按鈕。 – aromero 2011-04-26 02:36:27
雖然你想要的是QuickAction,但一個可能的和簡單的解決方案是使用QuickAction中使用的自定義Popupwindow – ingsaurabh 2011-04-26 04:45:34