Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android – ActionBar溢出菜单样式信息,用于手动实现大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试复制其他ActionBar项目的“溢出菜单”下拉列表功能.我正在努力手动实现这个功能,因为我认为它已被排除在环境之外(可能会强制UI的标准化).当您单击“溢出”菜单时,是否有人知道下拉列表中使用的样式/样式项?

编辑

溢出按钮实际上是一个修改过的微调器.这是它的样式信息.

<style name="Widget.Holo.Spinner" parent="Widget.Spinner.DropDown">
    <item name="android:BACkground">@android:drawable/spinner_BACkground_holo_dark</item>
    <item name="android:dropDownSELEctor">@android:drawable/list_SELEctor_holo_dark</item>
    <item name="android:popupBACkground">@android:drawable/menu_dropdown_panel_holo_dark</item>
    <item name="android:dropDownVerticalOffset">0dip</item>
    <item name="android:dropDownHorizontalOffset">0dip</item>
    <item name="android:dropDownWidth">wrap_content</item>
    <item name="android:popupPromptView">@android:layout/simple_dropdown_hint</item>
    <item name="android:gravity">left|center_vertical</item>
</style>

解决方法

这是我拼凑在一起的综述:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://scheR_580_11845@as.android.com/apk/res/android"
    android:id="@+id/dropdownContainer"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

    <LinearLayout
        android:id="@+id/leftBuffer"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1" />

    <LinearLayout
        android:layout_width="150dp"
        android:layout_height="match_parent"
        android:orientation="vertical" >

        <ListView
            android:id="@+id/actionbarDropdown"
            style="@style/Widget.ActionBarDropDown"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:cachecolorHint="@android:color/transparent"
            android:entries="@array/sortOptions" />

        <LinearLayout
            android:id="@+id/bottomBuffer"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/rightBuffer"
        android:layout_width="118px"
        android:layout_height="match_parent" />

</LinearLayout>

将onClick添加到ActionBar项目中:将上述布局作为子项添加到您的Activities根ViewGroup中,可以获得下拉列表的错觉.

将onClick添加到从根ViewGroup中删除视图的每个缓冲区允许在尝试移动焦点时将下拉菜单退出”.

下拉列表的样式信息是:

<item name="android:BACkground">@drawable/menu_dropdown_panel_holo_light</item>
<item name="android:dropDownSELEctor">@drawable/list_SELEctor_BACkground</item>

每个列表项的布局是:

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://scheR_580_11845@as.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="48dp"
      android:textSize="17sp"
      android:gravity="right|center_vertical"
      style="?android:attr/dropDownItemStyle"
      android:ellipsize="marquee"
      android:id="@android:id/text1">    
</TextView>

这并没有提供溢出下拉功能的完美副本,但它非常接近.我很感兴趣,如果有其他人知道以更集成的方式重现此功能方法

大佬总结

以上是大佬教程为你收集整理的android – ActionBar溢出菜单样式信息,用于手动实现全部内容,希望文章能够帮你解决android – ActionBar溢出菜单样式信息,用于手动实现所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。