Navigation Drawer clickable area - android

I have found a strange behavior on the clickable area for opening the Navigation Drawer:
Android 4.2.2+
The application icon and the action bar title are clickable (see red box on the image)
Android 4.2.2-
Only the application icon is clickable (see yellow box on the image)
Any workaround for this? I would like the Android 4.2.2- would have a bigger clickable area.

So, the reason this occurs is due to the way the ActionBarView inflates the home layout. Starting in Jelly Bean mr2, they added a layout called action_bar_up_container, which is added as a parent to the ActionBar home layout when it's first inflated. Before this; however, the action_bar_title_item wasn't added to the action_bar_up_container because it didn't exist and although contains a background, is only enabled and clickable when ActionBar.setDisplayShowHomeEnabled is set to false.
So, you could enable the title container and make it clickable like this:
final int abUp = getResources().getIdentifier("up", "id", "android");
final View titleContainer = (View) findViewById(abUp).getParent();
titleContainer.setEnabled(true);
titleContainer.setClickable(true);
But because of the way each View is inflated before Jelly Bean mr2, the up container and title container wouldn't be linked, so to speak.
So, it seems like the only workaround would be to attach a View.OnTouchLIstener to the titleContainer and implement some sort of pseudo-selection on MotionEvent.ACTION_DOWN and MotionEvent.ACTION_UP, which seems like more trouble than its worth to me, but if there's a better solution I welcome it.
Although, I suppose you could also call ActionBar.setCustomView and inflate a layout that mimics the home and title containers. This would probably be the easiest workaround.

Related

Implementing a floating dropdown panel for android toolbar

Iam working on an tablet app that needs a dropdown panel that flots on top of everything inclunding my toolbar. And should look something like
Can you please suggest the best UI widget that best suits this purpose, putting into consideration elevation and alignment inside the toolbar
For me it's a PopupWindow shown with showAsDropDown. You would have to prepare a layout with highlit back button and the product list. Then create a PopupWindow with that layout set as a content.
The other option is to prepare the popup as a custom, hidden layout lying on your main screen (use FrameLayout) and change its visibility when needed.
I'm not sure, but you may need a custom ViewOutlineProvider with convex path outline. PopupWindow may be unable to drop a non-rectangular shadow like on your screenshot. In such case you would have to set its background to transparent (or maybe null?), disable window's shadow and cast shadow with custom ViewOutlineProvider.

Android Actionbar PopupMenu with Custom Item Layouts

I am working on an Android application where I have to design a menu which will populate from the action bar, like this:
I have tried my best but was not able to produce it using the Android controls.
The solutions I have tried are:
With Actionbar, add a menu item with a group with selectable="all", that produces the layout I need but when I click a checkbox for selecting it, the whole menu hides and selection is not done, moreover the menu icon in actionbar does not have the bottom right white arrow.
Tried creating a custom ActionProvider and added the menu items using class's OnPrepareSubMenu method but had the same issue.
I just need a push in the right direction and I can do the rest, suggestions are more than welcome.
Thank you :)
Use popupWindow.
In that you can make any custom layout and set it as content of your popupwindow and also you can specify an ANCHOR in your case it would be
R.id.your_menu_item
set a listener and listen the changes.

how can I implement common Bottom bar which behave like tab?

I have implement bottom bar as show below I achieved this using view flipper, its work perfect but when I select any one item to start new activity, its blink because of activity change.
I want to make this bottom-bar behave like as tab in which only tab change and it wont blink activity.
Design a seperate layout with the Bottom images and their behavior (like using selector etc to change state when you click on it ) and add that layout to your Activity XML using
<include> </include> tag

Creating an Android Nav Bar that replaces button with image when that activity is active

I am looking to create a Nav Bar in my Android application that functions very similar to the Nav Bar used by the Netflix app. There will be 4 buttons aligned horizontally. When one of those buttons is selected, the appropriate activity loads and that button is replaced by an image.
There are multiple ways I can achieve this, but since I am new to programming for Android, I figured I'd ask the community first. I list the first two that come to my head below.
Create a Linear Layout and define a separate layout for each activity. The Layout would include two more linear layouts, a horizontal linear layout for the nav bar and a vertical layout for the content.
Create a custom ui component named nav bar that extends a linear layout (based upon earlier threads I have seen about nav bars on here). Inflate that layout for each activity, then make a framelayout that overlays an image on top of the active button (the button that was just pressed). Then create onButtonClick listeners for each button except for the active button.
I'm not sure if there is a better way to achieve this and I am open to any suggestions. Any feedback would be great.
I'm not sure how the netflix app looks, but you might want to check out ye good olde tab-layout? ( http://developer.android.com/resources/tutorials/views/hello-tabwidget.html )
Also be sure to take a look at the android design page: http://developer.android.com/resources/tutorials/views/hello-tabwidget.html

Custom Component in android

I have created custom component with a Button Bar on the Bottom of
the screen and a Title and status bar on the top of the screen. I want
to include this custom component in every one of my Activities. Now,
in a any given activity, how do I go about adding content on the
screen (say a button in the middle of the screen) in a addition to my
custom component thats ever present?
How about adding a base layout with can contain the header and footer that you use everywhere and then have a stub in the middle that you can inflate with whatever you like?
I think that will solve your problem.
You can read about ViewStub here:
http://android-developers.blogspot.com/2009/03/android-layout-tricks-3-optimize-with.html

Categories

Resources