ActionBar and CustomView - home button - java

I want to have a CustomView on my ActionBar that will define buttons, logos, etc. But I also want to make use of the Home Button and the ability to search in the ActionBar via a Search Interface. Is it possible to add, i.e. Home Button with icon on an ActionBar with Custom view layout?
Thanks

It is certainly possible to use a custom view on the action bar. The Strava android app does just that (or at least gives the appearance of an action bar at the top that has a non-standard layout).
Addressing your requirements one at a time: You can inflate a view of your own and assign it to the action bar:
View customView= getLayoutInflater().inflate(R.layout.customView, null);
getSupportActionBar().setCustomView(customView);
What you put in your view is, naturally, entirely up to you but you will have to manage everything yourself, including the home button actions. This includes the icon and text for the home button on the left hand side and search functionality. On a small device (especially in portrait mode) I'd go for a search icon only but on devices with more real estate you could fit a text input field in as well, using the alternative layouts feature to automatically pick up the most appropriate view for the device.

Related

Limit the click area on the view android

I need to limit the click area on the view. For example, I have a full-screen view, but I need only the top of the screen to be clickable, while clicking on the bottom should not give a result, how can I implement this? adding on top of the container doesn't help
You will need to create a click listener ONLY on the view you want to respond.
TopView.setOnClickListener()
BottonView (nothing).
If for some reason, your top View is not independent, just create another view that is transparent, and set a clickListener on that.

Android - Main menu for simple app

I'm making a simple android app, and I'm trying to work out the best way to make the main menu. The users of this app are not likely to be that sophisticated, so I want to make it as simple as possible.
So I want the first screen they see when the app opens to be this menu - they click on what they want, and it takes them to that part of the app (Not pressing a "Menu" button to bring it across from the left, which is common nowdays).
So, I want the menu to look a bit like this: http://cloud.addictivetips.com/wp-content/uploads/2012/10/AppZapp-Android-Menu.jpg , minus the search box, and the strip down the right hand side. (also this looks like it is one of those menus that slide out from the left, which I dont want)
I have had a look into menus (https://developer.android.com/guide/topics/ui/menus.html#options-menu), but it seems it is more used for contextual stuff, or letting the user select an option), then a navigation menu.
So - what is the best way to do this? Do I just create a list and put a button in each item?
Based on the your requirement , Use Navigation drawer see the below link.
Navigation drawer tutorial
NavigationDrawerSample
After used navigation drawer, you need to add search view on navigation header.For more info see the link
SearchView tutorial

Android action bar items on the left side of the action bar

I am required to create an action bar that has its items split: four of them on the right side and four on the left (it's a tablet-only application). In portrait mode they shouldn't be split. Is it possible to implement without using a custom view for the left side of the action bar, as it seems inconsistent?
Note that I want to know how to do it with the default action items, not with the custom ones in a custom view, and that I don't have any influence on the UI decisions, so please do not suggest to change the concept.
All ActionBar items are aligned to the right. It is not possible without custom view.
But you can use actionViewStyle for buttons to make them styled as menu items.
https://stackoverflow.com/a/13143180/1366471

Drop down menu from action bar - allowing drag and drop icons to be drawn to screen

as the title suggests I'm trying to add code to my app which allows the user to click on an item in the action bar menu which then unfolds a drop down menu (spinner class?) containing a few options such as lamp, tv etc. - each with an icon. The user will then be able to select one of these and drag and drop the icon (or an image representing the icon) to the canvas where it is then drawn. What is the best way to go about this?
If you're referring to the ActionBar overflow menu items, then you would have to take a look at the code for the ActionBar in the framework and extend it in your application, but that would firstly require quite a hassle and secondly would break compatibility when changes are made to the ActionBar in new versions of Android.
Also, this goes completely away from what the ActionBar is intended to be. You should only have actions in the overflow menu, not contain elements that directly interact with the Activity content. It's just wrong. Consider redesigning your UI so that you implement the requested featured inside the content view, not on the ActionBar.

Android activity navigation

I'm developing an app, where there is the main activity, it display some content (texts, images, etc), and a translucent menu on top of it. In this menu, I got link to other "screens" (implemented as Activities), on clicking it, I get correctly to the new activity, but the "activity changing animation" of the device blinks and then get me to the new activity.
I would like to make the navigation experience to be seamless on navigate through the screens, keeping my menu always on top of it. Today, this menu is implemented as a custom view (extending a Linear layout), also this menu will be expandable and collapsible, so the way it is I have to store the menu state through the activities.
PS: The way I've thought was to keep always two running activities, one for the current screen and another one for the menu, keep the menu on top, and just change the activity behind it. But could not find a way to do this...
PPS: Developing for Android 2.1
Anyone got an idea?
You should take a look at Fragments, or try to keep all functionality in one activity, changing only the content view.

Categories

Resources