Как добавить панель инструментов в Android Activity? - PullRequest
7 голосов
/ 26 апреля 2011

Официальный клиент Twitter для Android имеет красивую панель инструментов, когда вы нажимаете на сообщение, которое позволяет вам ретвитить, отвечать и т. Д. Как я могу заново создать такую ​​панель инструментов?

Ответы [ 2 ]

5 голосов
/ 26 апреля 2011

Для подхода 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

Вы также можетебудьте счастливы и с ActionBar, просто следите за требованиями API: http://developer.android.com/guide/topics/ui/actionbar.html

3 голосов
/ 26 апреля 2011

Мы называем это QuickAction:

enter image description here enter image description here

Узнайте больше о том, как реализовать это здесь: http://www.londatiga.net/it/how-to-create-quickaction-dialog-in-android/

...