2015-08-01 16 views

cevap

40

Bu bir widget değildir. Sonra

<ImageButton 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/ic_overflow_holo_dark" 
     android:contentDescription="@string/descr_overflow_button" 
     android:onClick="showPopup" /> 

: Bu belgeler öğretici ziyaretleri http://developer.android.com/guide/topics/ui/menus.html#PopupMenu

Bu yukarıdaki linkten güzel kod parçacığı atıfta için bir PopupMenu

içeren taşma simgesi kullanarak ImageButton (tarzında kenarlıksız) 'dir pop-up göstermek için kullanın:

public void showPopup(View v) { 
    PopupMenu popup = new PopupMenu(this, v); 
    MenuInflater inflater = popup.getMenuInflater(); 
    inflater.inflate(R.menu.actions, popup.getMenu()); 
    popup.show(); 
} 

Ve Roma Nurik bu harika bir araya getirdi

http://romannurik.github.io/AndroidAssetStudio/

ve görüntü mevcuttur: l herhangi Materyal Tasarımı simgesini almak istediğiniz

http://romannurik.github.io/AndroidAssetStudio/icons-actionbar.html#source.type=clipart&source.clipart=more_vert&source.space.trim=0&source.space.pad=0&name=ic_action_more_vert&theme=light&color=rgba(33%2C%20150%2C%20243%2C%200.6)

+0

denir UPDATE –

+0

Yukarıdaki aracı kullanarak doğru olana bir bağlantı eklendi - teşekkürler –

0

Web üzerinde buldum gibi, denir "taşma simgesi "veya taşma taşması".

Bu kod size yardımcı olabilir.

<menu xmlns:android="http://schemas.android.com/apk/res/android" > 

    <item 
     android:id="@+id/menu_red" 
     android:orderInCategory="1" 
     android:showAsAction="never" 
     android:title="@string/red_string"/> 
    <item 
     android:id="@+id/menu_green" 
     android:orderInCategory="2" 
     android:showAsAction="never" 
     android:title="@string/green_string"/> 
</menu> 
3

"orijinal" üç nokta Widget android.widget.ActionMenuPresenter.OverflowMenuButton (ActionMenuPresenter.java) 'dir (kod there arasındadır). Ne yazık ki özel bir sınıf. İşte çalışan bir kısa versiyon:

<!--White dots theme--> 
<style name="OverflowButtonTheme" parent="@style/Theme.AppCompat"> 
    <item name="actionOverflowButtonStyle">@style/Widget.AppCompat.ActionButton.Overflow</item> 
</style> 

<!--Dark dots theme--> 
<style name="OverflowButtonThemeLight" parent="@style/Theme.AppCompat.Light"> 
    <item name="actionOverflowButtonStyle">@style/Widget.AppCompat.Light.ActionButton.Overflow</item> 
</style> 
18

Ayrıca sadece actionOverflowButtonStyle bir stil özelliği ile ImageButton kullanabilirsiniz: ContextThemeWrapper ait

public class OverflowMenuButton extends AppCompatImageView 
{ 
    public OverflowMenuButton(Context context) 
    { 
     this(context, null); 
    } 

    public OverflowMenuButton(Context context, AttributeSet attrs) 
    { 
     this(context, attrs, 0); 
    } 

    public OverflowMenuButton(Context context, AttributeSet attrs, int defStyleAttr) 
    { 
     super(new ContextThemeWrapper(context, R.style.OverflowButtonTheme), attrs, R.attr.actionOverflowButtonStyle); 

     setClickable(true); 
     setFocusable(true); 
     setVisibility(VISIBLE); 
     setEnabled(true); 
    } 
} 

Temalar karanlık ve aydınlık sürümü almak için.

<ImageButton 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    style="?android:attr/actionOverflowButtonStyle"/> 
1
<vector xmlns:android="http://schemas.android.com/apk/res/android" 
    android:width="24dp" 
    android:height="24dp" 
    android:viewportWidth="24.0" 
    android:viewportHeight="24.0"> 
    <path 
     android:fillColor="#FF000000" 
     android:pathData="M12,8c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2zm0,2c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zm0,6c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2z"/> 
</vector> 
+0

zarif çözüm altında gördüğünüz @Laurent @Cristian – gnB

İlgili konular