Theme.AppCompat.Light.Dialog theme remove default app bar - android

I am trying to add a custom tool bar to this activity which uses the theme
Theme.AppCompat.Light.Dialog but the main issue is to remove the already existing default tool bar and put the custom tool bar on top.
I have tried creating new styles parenting the Theme.AppCompat.Light.Dialog theme with no luck.
Also the default tool bar doesn't have the settings popup icon as in the custom tool bar. Any ideas that you might have will surely be appreciated.
Found a Solution
Changed the style of the dialog by
<style name="Theme.AppCompat.Light.Dialog.custom">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
</style>
This style extends the Theme.AppCompat.Light.Dialog theme

Related

Android: preview shows different styling - action bar

Just started learning developing android in android studio, and created a custom theme which needs to hide the action bar on a inheriting styling.
On runtime the theme actually does hides the action bar but the preview does not, which makes it a bit difficult creating a layout based on the preview.
I've probably done something wrong or just not understanding how to use theme's and stylings with the preview correctly.
The custom theme I've made
<style name="AppTheme" parent="Theme.AppCompat">
...
</style>
<style name="AppTheme.MainLayout">
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style>
The intention is to use the .MainLayout styling on certain activities instead of the whole application.
How I'am applying the usage in manifest file
<application
...
android:theme="#style/AppTheme">
<activity android:name=".MainActivity"
android:theme="#style/AppTheme.MainLayout">
...
</activity>
</application>
As explained this does hides the action bar on runtime but doe'snt in the preview.
I also tested how the preview does behave on applying the style directly in the layout.xml file.
activity_main.xml
<RelativeLayout
...
android:theme="#style/AppTheme.MainLayout"
</RelativeLayout>
For testing purpose I've added an extra styling in the AppTheme.MainLayout
<item name="android:textColor">#color/colorPrimary</item>
Result
What I am observing on this is:
The preview doesn't hides the action bar but does apply other styling (like the text color) correctly.
To wrap this question up: why is the preview different on not hiding the action bar when using the .MainLayout, and how to fix this?
Thanks in advance.
Edit:
Preview 'settings'
In your Design layout manager try to select Theme (click AppTheme).
Try to change:
<style name="AppTheme" parent="Theme.AppCompat">
to:
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">

ShareActionProvider Drop down menu color from AppCompat v7

Just tried ShareActinProvider from AppCompat v7 and while the drop down from the action bar menu is light and good, the drop down from the ShareActionProvider share button is dark.
This is the style applied.
<style name="Theme.Pinnr" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#C62828</item>
<item name="colorPrimaryDark">#B71C1C</item>
</style>
I want both menus to have the same color.
Here is the bad menu image:
Here is the good menu image:
Update
I am in fact aware that I can change the color of that popup background with this code
<style name="Theme.Pinnr.listPopupWindowStyle" parent="Widget.AppCompat.Spinner.DropDown.ActionBar">
<item name="android:popupBackground">#eeeeee</item>
</style>
My question is why its happening and shouldn't just behave like the other menu. And hopefully how do I set it to match the other menu without hardcoding the color for the popup
Had the same issue and it was because I was based on Ligh.DarkActionBar theme. Changed to just the Light theme and it worked fine.

Customize each single Navigation Tabs separately using Actionbar java

i am using ActionBar to create an android app in eclipse with Tab Navigations and i would like to customize each of my tabs separately to add custom background color and icon to them. How can i set background, and icon to a tab on the ActionBar?
Thanks in advance!
When you create a new Android project/Android Activity, there are some templates you can choose from. Once of those should be for a tabbed navigation activity using ActionBar tabs. Somewhere in the generated code you'll see it's creating instances of ActionBar.Tab and adding them to the ActionBar. You can call setIcon() on the ActionBar.Tabs.
For theme customization, I recommend you use this website, it will generate all the necessary drawables and xml resources, and you can just drop those all into your project. ActionBar Style Generator
I just found a workaround for this problem. I'm still unable to customize each tab separately, but i can load a drawable background to the Navigation Tab Bar in the XML;
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="android:Theme.Light">
<item name="android:backgroundStacked">#drawable/tab_bg</item>
<item name="android:height">60dp</item>
</style>
The result is the following, which is exactly what i wanted;
http://i.imgur.com/DB9LRwD.png

ActionBarSherlock Back button color change ?

I am the using the ActionBarSherlock. I have the displayOption "homeAsUp" in my style.xml file. Now this shows a black arrow next to the title of the Activity. Since my theme is White on a blue blackground, i want to change the color of the black arrow, or maybe use a whole new icon resource in its place. How can i do this ?
Kind Regards.
Further to Eric's answer - I wasted a lot of time getting this right.
Remember that these items must go in the parent application theme, inheriting from Theme.Sherlock or similar.
<!-- CUSTOM APP THEME -->
<style name="AppTheme" parent="Theme.Sherlock">
<item name="android:actionBarStyle">#style/AppTheme.ActionBarStyle</item>
<item name="actionBarStyle">#style/AppTheme.ActionBarStyle</item>
<item name="android:homeAsUpIndicator">#drawable/action_bar_ic_ab_back_holo_dark</item>
<item name="homeAsUpIndicator">#drawable/action_bar_ic_ab_back_holo_dark</item>
</style>
Do not put them in the custom Action Bar theme inheriting from Widget.Sherlock.ActionBar.
<!-- ACTION BAR THEME -->
<style name="AppTheme.ActionBarStyle" parent="Widget.Sherlock.ActionBar">
<item name="android:icon">#drawable/action_bar_logo</item>
<item name="icon">#drawable/action_bar_logo</item>
<item name="android:displayOptions">showHome</item>
<item name="displayOptions">showHome</item>
</style>
Be careful when you style ActionBarSherlock !
Here is an extract from the web site (ActionBarSherlock Theming):
Due to limitations in Android's theming system any theme customizations must be declared in two attributes. The normal android-prefixed attributes apply the theme to the native action bar and the unprefixed attributes are for the custom implementation. Since both theming APIs are exactly the same you need only reference your customizations twice rather than having to implement them twice.
So in your case you MUST define two item:
<item name="android:homeAsUpIndicator">#drawable/icon</item>
and
<item name="homeAsUpIndicator">#drawable/icon</item>
Then you are sure that ALL your users will have the same L&F

Android how to style a SearchView in Actionbar?

I need to change the style of my SearchView in my ActionBar. In particular I need to change the text hint color and the SearchView icons if possible. How can I accomplish this in XML (is it even possible in XML)?
If this isn't possible, how can I easily recreate similar behavior with a custom view? The close/expand behavior of the SearchView is particularly useful for me.
Have you tried something like this (With ActionBarSherlock):
AutoCompleteTextView searchText = (AutoCompleteTextView) searchView.findViewById(R.id.abs__search_src_text);
searchText.setHintTextColor(getResources().getColor(R.color.white));
searchText.setTextColor(getResources().getColor(R.color.white));
It works fine for me.
It looks like you may need to supply a custom layout for your search action. I haven't been able to find any documents that talk about modifying the default SearchView. But this does allow the close/expand behavior.
http://developer.android.com/guide/topics/ui/actionbar.html#ActionView
Related questions:
Honeycomb - customize SearchView inside the action bar
set numeric input type to SearchView in ActionBar
You need to create a new theme and use it in manifest file.
<style name="Theme.Test" parent="#style/Theme.AppCompat.Light">
<item name="searchViewAutoCompleteTextView">#style/Theme.Test.SearchField</item>
</style>
<!-- Search edit text -->
<style name="Theme.Test.SearchField" parent="#style/Widget.AppCompat.Light.AutoCompleteTextView">
<item name="android:textColor">#color/white</item>
<item name="android:textColorHint">#color/white</item>
</style>
It worked fine for me.
The right answer is to overload the action bar widget style with your own custom style. For holo light with dark action bar, put this in your own styles file such as res/values/styles_mytheme.xml:
<style name="Theme.MyTheme" parent="#android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarWidgetTheme">#style/Theme.MyTheme.Widget</item>
<!-- your other custom styles -->
</style>
<style name="Theme.MyTheme.Widget" parent="#android:style/Theme.Holo">
<item name="android:textColorHint">#android:color/white</item>
<!-- your other custom widget styles -->
</style>
Make sure your application is using theme custom theme as described in enter link description here

Categories

Resources