I have 2 types of fragments between which I want to switch. Each time I create new instance of fragment I need.
In the first fragment I need to have clickable home icon so I set the appropriate (setDisplayShowHomeAsUpEnabled) display option to true and home icon starts look like an up. In the second one I don't need it so I set the appropriate display option to false and it stops looking as up. I'm listening to clicks on the action bar icon in parent activity.
The issue is that after second fragment is shown once the next time I show first fragment home icon remains clickable while it doesn't look like an up. The question is why is it clickable if currently visible fragment set it to not look like an up button?
I'm using appcompat-v7 library.
Please set the home buttom eanabled to false as well.
getSupportActionBar().setHomeButtonEnabled(false);
Lemme know if this works. :)
EDIT - One more way, but I am not sure on this.
You can set styles for your ActionBar title and over there you can set it as non-clickable as.
<item name="titleTextStyle">#style/TitleTextStyle</item>
and here is TitleTextStyle,
<!-- action bar title text -->
<style name="TitleTextStyle" parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#color/actionbar_text</item>
<item name="android:clickable">false</item>
</style>
Remember to do this for support library as well. Try and see if it does the trick.
Related
I added a toolbar item in my content page:
<ContentPage.ToolbarItems>
<ToolbarItem IconImageSource="icon_dropdown.png"/>
</ContentPage.ToolbarItems>
What I want to have is when a user clicks on the toolbar item, a menu pops down like this. Animated in a way where it slides down revealing the content/menu items.
I've been searching online but the keywords being searched always takes me to spinner, and being new to C# and Xamarin Forms, I am unsure if a spinner is still what I want to achieve something like this because a spinner looks more of a dialog box.
Sample image of what I'm trying to do that I've photoshopped
Any help is highly appreciated. Thanks.
I did some investigation, and find a way to change the position of the overflow popmenu by theme(code attached at the end in case you need it), but unable to change the width to match the whole screen, not sure if Android made some limitations in menu.
If you need a drop down list exact the same of your picture, spinner may not be a perfect choice either, you'd better create a new activity that overlays origin activity and customize the new activity layout, but it's not recommended considering performance. Also, you can find something in an earlier post to see if it gives you any idea.
add a new style:
<style name="OverflowMenuStyle" parent="#style/ThemeOverlay.AppCompat.Light">
<item name="overlapAnchor">false</item><!--not overlay the toolbar-->
<!--<item name="android:dropDownWidth">10dp</item> not work-->
<!--<item name="android:maxWidth">400dp</item> not work-->
<item name="android:paddingRight">0dp</item>
<!--dropDownVerticalOffset is the property you want to avoid overlay the toolbar-->
<item name="android:dropDownVerticalOffset">4dp</item>
<item name="android:dropDownHorizontalOffset">0dp</item>
<item name="android:popupBackground">#BFBFBF</item>
</style>
Android Resource layout folder's Toolbar.xml, change popupTheme to:
android:popupTheme="#style/OverflowMenuStyle"
add an item in MainTheme.Base style:
<item name="actionOverflowMenuStyle">#style/OverflowMenuStyle</item>
i'm using actionbarsherlock for my actionbar. I have a sliding menu and searchview. when the application get launches, it will automatically pick the up navigation icon from style.xml file.
When the search menu gets expanded, the up navigation icon will not get changed, it will be still looking like 3 line slider menu. How to change the up navigation icon when searchview is expanded?. I have represented the flow in below image.
Create custom back button theme with parent of your custom theme.
<style name="MyThemeForSearch" parent="#style/MyCustomTheme">
<item name="android:homeAsUpIndicator">#drawable/my_back_indicator_for_search</item>
</style>
Set theme in runtime when Search is expanded., i.e onClick
setTheme(R.style.MyThemeForSearch);
check your layout drawable's whether you have set an image like 3 liner slide menu
when you create navigation drawer it automatically sets default image which will be loaded representing 3 liner slide like you mentioned change your ic_drawer.png image and replace image with what icon you wish.
also you might go check changing your theme
> <style name="Theme.MyFancyTheme" parent="android:Theme.Holo">
> <item name="android:homeAsUpIndicator">#drawable/my_fancy_up_indicator</item>
> </style>
I'm trying to make just one activity of my app overflowing behind the software keys, like this
What I already did was to put in my theme definition the following statements
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
and then enabled it on the listView I wanted to overlap
android:fitsSystemWindows="true"
android:clipToPadding="false"
What happened was that my app did overlap on status bar and button bar, but this on EVERY activity and not just on the one I put the two rows above.
Also, it messed up my activity margins: the first row of my application drawer is hidden, and the top of my main fragment as well.
I thought fitsSystemWindows was meant to solve this kind of issues, so I added it to my theme
<item name="android:fitsSystemWindows">true</item>
but nothing changed.
So the question is apparently simple: how can I get the translucent bottom bar, with one of my activities flowing behind it, without messing up the top part of my app and without (if possible) having the same effect on all other activities?
Thank you in advance to each of you fellow helpers.
As Eluvatar stated if I need to have this effect on just one activity the best thing to do is to define a custom theme and assign it just to this activity. That's what I did, I defined an empty style in styles.xml and overrided it in values-v19/styles.xml putting just
<!--<item name="android:windowTranslucentStatus">true</item>-->
<item name="android:windowTranslucentNavigation">true</item>
Then I assigned - in AndroidManifest.xml, the proper style to the activity by using
android:theme="#style/Theme.Style.I.Created.For.This.Activity"
Disabling the first row allowed the activity to just overlap the navigation bar without popping out on the status bar. Margins seem ok as well.
I hope this is going to help somebody else someday.
I want to delete the confirm button that appears on left side of CAB when my app si in selection mode. Or replace it with a back button.
I have a single selection mode, so, in contextual action bar I need only title, and a back button.
I follow android tutorial and all work fine, but now how can I remove default confirm ?
You can change the icon on the top left by changing it in the theme.
If you styles.xml, create a new theme if you don't have one already.
<style name="Theme.Custom.Light" parent="Holo.Theme.Light">
<item name="android:actionModeCloseDrawable">#drawable/ic_menu_checkmark</item>
</style>
You can put in any drawable here. Just tried it and it worked.
In my android app, in the Action Bar, next to the < image is an icon. I want to make it invisible/gone ondemand dynamically. How do I do that? The icon is actually defined as follows (this should help you realize where in the action bar I am talking about).
<style name="MyAppName.LogoTheme.LogoActionBar" parent="MyAppName.Theme.ActionBar">
<item name="android:displayOptions">showHome|homeAsUp</item>
<item name="android:icon">#drawable/my_icon</item>
I tried the following, but nothing.
this.getActionBar().setDisplayHomeAsUpEnabled(false);
this.getActionBar().setLogo(null);
this.getActionBar().setDisplayUseLogoEnabled(true);
In Java, call setDisplayShowHomeEnabled(false) and setDisplayShowTitleEnabled(false) on your ActionBar.