Issue
In my android app, when I press the actionbar menu, it gets a blueish glow to it. How can I prevent it from happening?
Is it possible to do so for only one menu and keep it running for others?
<style name="MyActionBar" parent="@android:style/Widget.Holo.ActionBar">
<item name="android:background">@drawable/action_bar_background</item>
<item name="android:selectableItemBackground">@android:color/transparent</item>
</style>
Solution
You can change the selector of a particular action bar item by setting a custom ActionView in the code:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getSupportMenuInflater().inflate(R.menu.activity_main, menu);
MenuItem menuItem = menu.findItem(R.id.menu_include_location);
ImageView image = new ImageView(this);
image.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT));
image.setImageResource(R.drawable.ic_launcher);
image.setBackgroundResource(R.drawable.icon_place_selector);
image.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// ...
}
});
menuItem.setActionView(image);
return true;
}
you can use transparent color for pressed state in icon_place_selector.xml,
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Pressed -->
<item android:state_pressed="true" android:drawable="@android:color/transparent" />
</selector>
Answered By - Navaneeth
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.