0

我正在尝试做类似下面的样机。我需要第一个项目与其他项目有不同的背景。我也需要这第一个项目是不可点击的。我尝试了enabled =“false”属性,但是却弄脏了我不想要的文字。另外我已经尝试了styles.xml中的itemBackground来更改项目背景颜色,但是这改变了所有这些颜色,我只希望第一个项目具有不同的背景。最后,我希望在最后两项中有一些缩进(不确定这是否可能,因为我没有看到填充和边距属性)。是否可以通过背景色和填充来自定义菜单项?

enter image description here

+0

是的,这是可能的 –

+0

@shweta你知道该怎么办呢? – Nico

回答

0

添加弹出菜单样式UR AppTheme:

<style name="AppTheme" parent="android:Theme.Light"> 
    <item name="android:popupMenuStyle">@style/PopupMenu</item> 
</style> 

<style name="PopupMenu" parent="@android:style/Widget.PopupMenu"> 
    <item name="android:popupBackground">@android:color/white</item> 
</style> 

的manifest.xml:

<application 
    android:allowBackup="true" 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" 
    android:theme="@style/AppTheme" > 
............. 
</application>