What I'm trying to do is hide a custom title bar when the user edits text in my app, so as to give him a wider view. I can blank the elements inside the title bar just fine but that just makes empty space; I am trying to make the app window expand to take advantage of that space dynamically.
I've already setup a custom title bar, which is integral to the navigation of my app. It allows the user to jump between fragments. I am only trying to temporarily hide the title bar.
I am using the following custom theme:
<style name="GTTheme2" parent="#android:style/Theme.Holo">
<item name="android:windowNoTitle">false</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowTitleSize">37dp</item>
<item name="android:windowSoftInputMode">adjustResize</item>
</style>
In my activity I have.
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.gtDisplay);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,
R.layout.custom_title_gt_phone);
I have tried the following
getActivity().getActionBar().hide();
That returns a null pointer exception because the action bar doesn't exist because I set up a custom title. I tried setting "Android:windowActionBar" to true my theme, but apparently the setting conflicts with setting up a custom title bar, as my app failed to load.
I also tried
getActivity().setTheme( <<some new theme here>>);
Where the new theme didn't have a title or had 0dp for windowTitleSize, but screen didn't change.
Tried searching if there is a way to set windowTitleSize dynamically (other than as a startup theme in AndroidMainfest) but haven't found anything. Any thoughts?
Related
I have a DialogFragment which consists of a search EditText and a RecyclerView. When you click on a search item, dialog is dismissed and selected item is added to another list in the parent fragment.
I use navigation controller to navigate between fragments. This DialogFragment is currently defined with fragment tag in navigation graph XML. I use findNavController().navigate(destinationId) to open it and findNavController().popBackStack() to close it.
I want to show it as dialog in tablets and full screen on mobile devices but failed to do so.
I tried to create a custom dialog theme whose parent is Theme.MaterialComponents.DayNight.DialogWhenLarge and set it as dialogTheme in the app theme but it overrides attributes in the app theme, like status bar color. I also tried many solutions offered in questions asked here.
How can I achieve this?
When I worked with Diologs set attribute in theme mad them fullscreen
<style name="NotificationDialogTheme" parent="android:Theme.Holo.Dialog">
<item name="android:windowMinWidthMajor">100%</item>
<item name="android:windowMinWidthMinor">100%</item>
</style>
I want to put a picture on my action bar, instead of the text (No, I am not using action bar sherlock), and if possible for the action bar to be transparrent AND with detectable height (I have done transparent action bar before, but you can't get its height programatically this way).
It should be in styles somehow, not programatically. Right now I have this styles.xml and it does absolutely nothing...
<resources>
<style name="AppTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/AppTheme.ActionBarStyle</item>
</style>
<style name="AppTheme.ActionBarStyle" parent="android:style/Widget.Holo.Light.ActionBar">
<item name="android:icon">#drawable/img_ab_youlocal_logo</item>
</style>
P.S. YES, I have searched before asking, the other asnwers were not helpful.
If you are using an api < 21 you could do something similar this:
ActionBar actionbar = getActionBar();
actionbar.setDisplayShowCustomEnabled(true);
actionbar.setCustomView(R.layout.someLayoutfile);
You may have to this before the Parent View gets inflated / set via setContentView();
Also in api > 11 you have a logo attribute:
Using a logo instead of an icon
By default, the system uses your application icon in the action bar, as specified by the icon attribute in the
<application> or <activity>
element. However, if you also specify the logo attribute,
then the action bar uses the logo image instead of the icon.
A logo should usually be wider than the icon, but should not include unnecessary text.
You should generally use a logo only when it
represents your brand in a traditional format that users recognize. A
good example is the YouTube app's logo—the logo represents the
expected user brand, whereas the app's icon is a modified version that
conforms to the square requirement for the launcher icon.
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.
So, I want to use a View in place of the app icon in the actionbar. I can't use a simple image because the View will change its colours depending of the set of colors chosen in the parameters of the app (and I don't want to create four hundred images in photoshop...).
I know I can use a custom view for the action bar and it's even quiet easy, but the problem is that the original app image is still shown. I also know that I can hide it by setting setDisplayShowHomeEnabled to false, but that also hides the glyph of my navigation drawer and that is the problem.
I also tried to create a custom Drawable and override the onDraw method but nothing was shown and the Drawable has 1px height/width.
To hide the icon you can use a transparent one, edit the style you use for your actionbar like this :
<style name="MyActionBarStyle" parent="#style/Widget.Sherlock.Light.ActionBar">
<item name="icon">#android:color/transparent</item>
</style>
assuming you use as style named MyActionBarStyle for your actionbar in your theme.
<style name="AppBaseTheme" parent="#style/Theme.Sherlock.Light">
<item name="actionBarStyle">#style/MyActionBarStyle</item>
</style>
I want to hide the Status Bar in my app and maintain the ability for the virtual keyboard to adjustResize for ScrollViews.
This:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
does not work because it breaks all ScrollViews preventing the adjustResize from resizing the view allowing the user to scroll when the keyboard is visible, so this is not an acceptable answer.
I've got:
<item name="android:windowNoTitle">true</item>
In my base theme, and I tried putting that setting directly into the Manifest entry for my activity, but it doesn't do anything.
I am using ActionBarSherlock in my app so I can provide a uniform UI to my users and it requires that I use one of three base themes:
In order for the custom action bar implementation to function your
application must use Theme.Sherlock, Theme.Sherlock.Light, or
Theme.Sherlock.Light.DarkActionBar, or your custom theme must use one
of the aforementioned as its parent.
So, I've configured my Theme this way:
<style name="LightNoTitleBar" parent="Theme.Sherlock.Light.DarkActionBar">
<item name="android:windowNoTitle">true</item>
</style>
and I've got android:theme="#style/LightNoTitleBar" in my manifest entry for this activity.
So, how can I hide the status bar given the above restrictions?