How I make a logo and actionBar transparent? - android

I am using a .png for both my logo and action Bar menu items. I am using the android.Holo.light theme.
Even though I've made the background transparent for both the logo and the menu items, a grey shaded area is still showing behind the .png. How do I change this?
Take a look at my menu XML and my style override XML below.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyTheme" parent="android:Theme.Holo.Light">
<item name="android:selectableItemBackground">#color/transparent</item>
<item name="android:background">#00000000</item>
</style>
<style name="ActionBar" parent="#android:style/Widget.Holo.Light.ActionBar" >
<item name="android:selectableItemBackground">#color/transparent</item>
<item name="android:background">#00000000</item>
</style>
<style name="textTitle"
parent="#android:style/TextAppearance">
<item name="android:textSize">20dp</item>
<item name="android:textColor">#DC0451</item>
<item name="android:textStyle">bold</item>
</style>
<style name="textDescription"
parent="#android:style/TextAppearance">
<item name="android:textSize">15dp</item>
<item name="android:textColor">#666666</item>
</style>
</resources>
Menu xml
<item
android:id="#+id/Category"
android:title="Category"
android:showAsAction="always|withText"
android:icon="#drawable/menuitemselect"
style="#style/ActionBar"
>
<menu>
<item
android:id="#+id/catalog"
android:title="Main Catalog"
android:icon="#drawable/menuitemselect"
android:onClick="catalogClick"
/>
<item android:id="#+id/newvideos"
android:title="New"
android:icon="#drawable/menuitemselect"
android:onClick="newVideoClick"
style="#style/ActionBar"
/>
<item
android:id="#+id/popularvideos"
android:title="Popular"
android:icon="#drawable/menuitemselect"
android:onClick="popularVideoClick"
style="#style/ActionBar"
/>
</menu>
</item>
<item android:id="#+id/backButton"
android:title="Back"
android:showAsAction="ifRoom"
android:icon="#drawable/ic_launcher"
/>
</menu>
Thank you

I found that the issue was with :
<item name="android:selectableItemBackground">#color/transparent</item>.
I added it in an attempt to get rid of default highlight feature. It seems when I have this set, the grey background shows up. When I remove it, it acts as it should.

Related

How to change background color option menu xamarin android

i try change background color option menu from black to white
but my code not work.i see this link too How to change background color popup menu android but its not work for me.
styles
<style name="Theme.DesignDemo" parent="Base.Theme.DesignDemo">
</style>
<style name="Base.Theme.DesignDemo" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/ColorPrimary</item>
<item name="popupMenuStyle">#style/PopupMenu</item>
<item name="colorPrimaryDark">#color/ColorPrimaryDark</item>
</style>
<style name="PopupMenu" parent="Widget.AppCompat.PopupMenu">
<item name="android:popupBackground">#android:color/white</item>
</style>
</resources>
popup_menu.xml:
<?xml version="1.0" encoding="utf-8" ?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto">
<!--///showAsAction="always" ///-->
<item android:id="#+id/action_settings" android:title="Share" showAsAction="always" />
<item android:id="#+id/action_settings1" android:title="Bluetooth" showAsAction="always" />
<item android:id="#+id/action_settings2" android:title="Exit" showAsAction="always" />
<!--/android:showAsAction="ifRoom"/-->
<item android:id="#+id/action_settings3" android:title="Share" android:showAsAction="ifRoom" />
<item android:id="#+id/action_settings4" android:title="Bluetooth" android:showAsAction="ifRoom" />
</menu>
How to change background color option menu
Have you controlled the context you passed to the constructor? When you create a PopupMenu class, please use the Activity context like this :
PopupMenu popup = new PopupMenu(this, anchorView);//Not BaseContext
Whether you use android.widget.PopupMenu or android.support.v7.widget.PopupMenu? They governed by different theme attributes :
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- if using android.widget.PopupMenu -->
<item name="android:popupMenuStyle">#style/PopupMenu</item>
<!-- if using android.support.v7.widget.PopupMenu -->
<item name="popupMenuStyle">#style/PopupMenu</item>
</style/>
<style name="PopupMenu" parent="Widget.AppCompat.PopupMenu">
<item name="android:popupBackground">#android:color/white</item>
</style>
Effect like this.

How to make textview's background transparent when it is the child of the layout

I have a textview in a layout and I set the click listener to the layout and layout's color was changed when the layout is pressed. However I want to set a textview's background to transparent but it can't. It take the window's background (the window's background is gray, my layout's background is white) instead of the layout's background.
<LinearLayout android:layout_width="match_parent"
android:layout_height="50dp"
style="#style/TestLayout">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="Test"
android:background="#android:color/transparent"/>
</LinearLayout>
In styles.xml
<style name="TestLayout" parent="AppTheme.NoActionBar">
<item name="android:background">#drawable/selector_test_small_layout</item>
</style>
In selector_test_small_layout
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_pressed="true" android:state_enabled="true"
android:drawable="#drawable/s_pressed_layout" />
<item android:state_hovered="true" android:state_enabled="true"
android:drawable="#drawable/s_pressed_layout"/>
<item android:state_enabled="true" android:drawable="#drawable/s_color_primary"/>
<item android:state_enabled="false" android:drawable="#drawable/s_color_primary"/>
</selector>
UPDATED: Sorry about my xml is not fully enough. Tomorrow I'll update it correctly Y_Y. Now I dont have source code, only have picture
UPDATED: I included the more content in the styles.xml
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="android:windowContentOverlay">#null</item>
<item name="colorPrimary">#color/colorPrimary</item>
**<item name="android:windowBackground">#color/setting_divider</item>**
</style>
In AndroidManifest.xml
<application
android:name=".TestApplication"
android:allowBackup="true"
android:icon="#drawable/icon"
android:label="#string/app_name"
android:largeHeap="true"
android:supportsRtl="true"
**android:theme="#style/AppTheme**">
....
</application>
I checked with the code added above, I could not see any issue at all. Could you please share the snapshot of screen to point out exact issue. Also you can try with setting the background="#null" on TextView.
When TextView.Background is null, textView will be take, parent background
Little bit old but hope so it helps somebody else
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">#drawable/backfull</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowActionModeOverlay">true</item>
<item name="windowActionModeOverlay">true</item>
</style>
<style name="AppTheme2" parent="AppTheme.Base">
<item name="colorPrimary">#drawable/backfull</item>
<item name="colorPrimaryDark">#android:color/white</item>>
<item name="colorAccent">#android:color/black</item>
<item name="colorButtonNormal">#android:color/white</item>
</style>
<style name="ToolbarTheme" parent="Widget.AppCompat.Toolbar">
<item name="android:background">#drawable/backfull</item>
<item name="background">#android:color/black</item>
<item name="titleTextAppearance">#style/ToolbarTitleTheme</item>
<item name="popupTheme">#style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
<item name="theme">#style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
</style>
<style name="ToolbarTitleTheme">
<item name="android:textColor">#android:color/holo_red_dark</item>
<item name="android:textStyle">bold</item>
</style>

Increase spacing between action buttons?

This is my menu.xml at the moment
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="#+id/action_save"
android:title="Save"
android:icon="#drawable/ic_action_save"
app:showAsAction="ifRoom|withText" />
<item
android:id="#+id/action_delete"
android:title="Delete This"
android:icon="#drawable/ic_action_delete"
app:showAsAction="never"/>
</menu>
However, the spacing between the overflow menu and the main Save button is pretty small. I'd like to add more spacing.
Here is my styles.xml
<resources>
<style name="MyTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- ... -->
<item name="android:actionButtonStyle">#style/MyActionButtonStyle</item>
</style>
<style name="MyActionButtonStyle" parent="Widget.AppCompat.Light.ActionButton">
<item name="android:paddingEnd">100dip</item>
<item name="android:paddingRight">100dip</item>
<item name="android:layout_marginRight">100dip</item>
<item name="android:horizontalSpacing">100dip</item>
</style>
<!-- ... -->
</resources>
Unfortunately, that style has no effect.
The only thing I can get to work is <item name="android:minWidth">300dp</item>. I am using this for now, but the problem is I am going to have various buttons of different widths, so it would be much better if I could set spacing or padding instead of min-width.
Why are all of my padding rules of 100dip not working, and what should I do instead?
Found solution, added following lines in styles.xml file and it worked!!
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:actionButtonStyle">#style/MyActionButtonStyle</item>
</style>
<style name="MyActionButtonStyle" parent="AppBaseTheme">
<item name="android:minWidth">20dip</item>
<item name="android:padding">0dip</item>
</style>

Styling popup menu item's

I am trying to style the items of my popup so they look like a list of buttons below eachother. The only problem is that I can't get to change anything of the popup items. I have tried to set a global popupMenuStyle in my app style but that didn't to anything. I tried to set an actionLayout on the menu items but still no change.
How can I change the styling of my popup menu items?
My menu:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#+id/test1"
android:title="Test" />
<item android:id="#+id/test2"
android:title="Test 2" />
</menu>
How I open the popup menu:
PopupMenu popupMenu = new PopupMenu(getContext(), mButton);
popupMenu.getMenuInflater().inflate(R.menu.popup_menu, popupMenu.getMenu());
popupMenu.show();
Try this as part of your styles.xml file:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:popupMenuStyle">#style/PopupMenu</item>
<item name="android:textAppearanceLargePopupMenu">#style/myPopupMenuTextAppearanceLarge</item>
<item name="android:textAppearanceSmallPopupMenu">#style/myPopupMenuTextAppearanceSmall</item>
</style>
<style name="PopupMenu" parent="#android:style/Widget.PopupMenu">
<item name="android:popupBackground">#FFFFFF</item>
<item name="android:divider">#444444</item>
<item name="android:dividerHeight">1px</item>
<item name="android:background">#FFFFFF</item>
</style>
<style name="myPopupMenuTextAppearanceSmall" parent="#android:style/TextAppearance.DeviceDefault.Widget.PopupMenu.Small">
<item name="android:textColor">#000000</item>
<item name="android:textSize">12sp</item>
<item name="android:background">#FFFFFF</item>
</style>
<style name="myPopupMenuTextAppearanceLarge" parent="#android:style/TextAppearance.DeviceDefault.Widget.PopupMenu.Large">
<item name="android:textColor">#000000</item>
<item name="android:textSize">18sp</item>
<item name="android:background">#FFFFFF</item>
</style>
</resources>
and then in your xml layout file for the activity add this line:
style="#style/AppTheme"
or in your AndroidManifest.xml file, add this to the application tag:
android:theme="#style/AppTheme"
This will affect how Android renders a popup menu in your app.

change the android actionbar submenu text color

How to change the text color of submenu in Android? I customize the application theme and override the relative attributes, but it still doesn't work. My menu has two submenus, which are initially hidden, when clicked, it shows. However, the style of submenus can't be modified, while the title of action bar can. This question bothers me all the day, I almost try every ways I find.
This is my code!
menu.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.example.classsignin.MainActivity" >
<item
android:id="#+id/action_overflow"
android:title="分享"
android:icon="#drawable/drop_select"
android:showAsAction="always"
>
<menu >
<item
android:id="#+id/absent"
android:title="请假"
android:icon="#drawable/absent"
/>
<item
android:id="#+id/refresh"
android:title="刷新课程"
android:icon="#drawable/refresh"
/>
</menu>
</item>
styles.xml
<style name="CustomTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyActionBarTheme</item>
<item name="android:actionMenuTextAppearance">#style/MyActionBarMenu</item>
<item name="android:actionMenuTextColor">#color/blue</item>
<item name="android:homeAsUpIndicator">#drawable/back</item>
<item name="android:spinnerItemStyle">#style/MySpinnerItem</item>
</style>
<style name="MyActionBarTheme" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#color/white</item>
<item name="android:titleTextStyle">#style/MyActionBarTitle</item>
</style>
<style name="MyActionBarTitle" parent="#android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textSize">16sp</item>
<item name="android:textColor">#color/blue</item>
</style>
<style name="MyActionBarMenu" parent="#android:style/TextAppearance.Holo.Widget.ActionBar.Menu">
<item name="android:textSize">16sp</item>
<item name="android:textColor">#color/blue</item>
</style>
<style name="MySpinnerItem" parent="#android:style/Widget.Holo.TextView.SpinnerItem">
<item name="android:textAppearance">#style/MyTextAppearance</item>
</style>
<style name="MyTextAppearance" parent="#android:style/TextAppearance.Holo.Widget.TextView.SpinnerItem">
<item name="android:textColor">#color/blue</item>
</style>
Essentially you will want to customise your MenuItem's style by having the android:itemBackground attribute overridden with your custom color/drawable selector in your style.xml and as well a vtextColor` attribute to override.
In case your menu has also submenu's, then you will want as well to style the header title of the submenu, which usually is automatically with White background by overriding the attribute actionBarPopupTheme with your custom style.
style.xml
<resources>
<style name="AppTheme" parent="Theme.AppCompat.DayNight.DarkActionBar">
<item name="android:itemBackground">#drawable/menu_popup_selector</item>
<item name="actionBarPopupTheme">#style/SubmenuHeaderStyle</item>
</style>
<style name="SubmenuHeaderStyle" parent="ThemeOverlay.AppCompat.Light">
<item name="android:colorBackground">#color/colorPrimary</item>
<item name="android:textColor">#color/colorAccent</item>
</style>
</resources>
menu_popup_selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<color
android:color="#color/colorPrimary"/>
</item>
<item>
<color
android:color="#655611"/>
</item>
</selector>
And you will have something like those screenshots
(1st menu and then the submenu after clicking one item on the 1st menu - the pink header is my submenu header).
Just for you to know when I have the normal menu without submenu would look like this hierarchy views:
<menu>
<item/>
<item/>
<item/>
</menu>
and a menu with submenu as this example of hierarchy views:
<menu>
<item/>
<item/>
<group>
<item>
<menu>
item
item
item
</menu>
</item>
</group>
<item/>
<item/>
</menu>

Categories

Resources