Как называется маленький виджет с тремя точками внутри кард-андроида?
Что такое маленький виджет с тремя точками? Как добавить его в свое приложение?
Как называется маленький виджет с тремя точками внутри кард-андроида?
Что такое маленький виджет с тремя точками? Как добавить его в свое приложение?
Это не виджет. Это ImageButton
(без полей в стиле), используя значок переполнения, который включает в себя PopupMenu
Для документации учебных визитов http://developer.android.com/guide/topics/ui/menus.html#PopupMenu
Это относится к хорошему фрагмента кода по ссылке выше:
<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" />
Тогда чтобы показать всплывающее окно:
public void showPopup(View v) {
PopupMenu popup = new PopupMenu(this, v);
MenuInflater inflater = popup.getMenuInflater();
inflater.inflate(R.menu.actions, popup.getMenu());
popup.show();
}
И Роман Нурик вместе поставил вместе эту удивительную л, чтобы получить какой-либо материал значок Design вы хотите:
http://romannurik.github.io/AndroidAssetStudio/
и изображение доступно по адресу:
добавил ссылку на правильный с помощью этого инструмента выше @Cristian –
@Laurent см под UPDATE –
Как я нашел в Интернете, это называется «значок переполнения "или переполнение действия".
Возможно, этот код может вам помочь. (Код от there)
<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>
"Оригинальный" три дота виджет является android.widget.ActionMenuPresenter.OverflowMenuButton
(ActionMenuPresenter.java). К сожалению, это частный класс. Здесь работает более короткая версия:
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);
}
}
Тематика ContextThemeWrapper
, чтобы получить темный и светлый вариант:
<!--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>
Вы также можете просто использовать ImageButton
с атрибутом actionOverflowButtonStyle
стиля.
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:attr/actionOverflowButtonStyle"/>
<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>
элегантное решение - благодаря – gnB
⋮ - этот символ также называется «вертикальным многоточием» –