How to make a scrollable view that automatically scrolls to fixed positions - java

I am developing a resource for Machinists to use on their phone. It has lots of shop information in it. And I would like to include a calculator that can do a little bit of trig.
I am creating a button layout with all of the input keys, instead of using the android keyboard. I want to have two layouts side by side. The user will be able to scroll horizontally to get to one from the other.
Algeo, a great scientific calculator on Android, has an example of this. Algeo's keyboard is 3 different sets of buttons. And you can scroll horizontally between them. If you scroll halfway through two button layouts, it will automatically scroll it so one is centered. It will not let you scroll so you have 1/3rd of one layout, and 2/3rd's of another, or any other way you could split them.
I would like to know how to replicate this. I assume I need to use a container other than HorizontalScrollView, but, I'm unsure of what container it would be.

Related

Android Recyclerview alternative for widget

I have a use case were a user can create own buttons and give each button a label.
To display the buttons correctly i use Recyclerview with StaggeredGridLayoutManager. This works like a charm.
Unfortunately Recyclerview is not supported on Android Widget.
What do you think is the best solution to display an arbitrary amount of buttons (each button can be of different sizes) on a widget? Should I use a GridLayout?
You can find here all the layouts that are supported to use in android widgets.
Of all the supported layouts listed the one that is closer in appearance to StaggeredGridLayout is the GridLayout. So, I would pick GridLayout to start with and then depending on my design needs I would combine it with what fits my needs best. Most probably, if you want to keep StaggeredGridLayout's default appearance, maybe you can combine it with some LinearLayouts wherever needed.

Android HorizontalScrollView Snap and Center Focus

Fairly new to Android dev. I am trying to create a HorizontalScrollView that snaps and filters images based on the centered object selected in a list. In the picture below, notice how the letter in the center of the screen should perform a set of specific commands. For example, when I scroll to "C" a popup with the message "C" should pop up.
I have created the HorizontalScrollView and populated the view with buttons. I am trying to figure out how to make it snap and how to identify the letter in the center at any given moment.
I have taken a look at ViewPager, but I don't think it will be able to do what I have described because I would like to have a set of letters displayed at any moment. I understand I will probably have to create a custom class. Could you provide any guidance?

How to create a custom android button overlay?

So to expand on the question stated, to my best understanding android apps have a set of activities such as the default activity_main.xml and you could even generate a login screen (activity_login.xml). After fiddling around with it I sort of feel comfortable with the way buttons work, yadda yadda, but my problem emerges when I want to create a game activity. I am not concerned about that part, I would just make another activity (activity_gameplay.xml) that I would run the game on. My problem is that I want to render my own custom buttons onto the screen which would be transparent and would be stationary while the actual game environment would be moving. Such as in Minecraft(android version obviously).
So to conclude I need to know how to render custom buttons, and though not included in the above, how to position the buttons accordingly sense the XML way only allows stuff such as upper left-hand corner etc.

how to setup this gui

Im having quite a difficult time setting up this GUI
As you can see in the picture i need to have several clickable items and i dont know how to do it. So i thought i could make one different VerticalFieldManager representing the white background. But it looks impossible to have more than two VerticalFieldManager over the main manager. So i thought i could use a LabelField and change the background color to white (it didnt work either) and on top of it put clickable labels and clickable textField but i dont get the background VerticalFieldManager to repeat it self and put itself under the previous one with a slight margin between them. Anyways, can you guys give me ideas on how to accomplish this GUI, what to use as background.
Thanks in advance and have a nice one.
I would suggest the following layout
Screen delegate should be VerticalFieldManager
Each item should be VerticalFieldManager as well
The body of the item itself should be RichTextField
The rest of the clickable elements you mentioned should be clickable Labels.
You will have to use HorizontalFieldManagers as well. One for the top panel and one for the bottom panel. Check the JustifiedHorizontalFieldManager from the advanced UI libarary.
As for clickable label - it is easy to implement one. Search SO for "[blackberry] clickable label". You can also check the BaseButtonField and BitmapButtonField provided in BlackBerry advanced UI library and available here.

Blackberry - How to implement ListField Smooth Scrolling?

Overview
I'm using a listfield class to display a set of information vertically. Each row of that listfield takes up 2/5th's of the screen height.
As such, when scrolling to the next item (especially when displaying an item partially obscured by the constraints of the screen height), the whole scroll/focus action is very jumpy.
I would like to fix this jumpiness by implementing smooth scrolling between scroll/focus actions. Is this possible with the ListField class?
Example
Below is a screenshot displaying the issue at hand.
(source: perkmobile.com)
Once the user scrolls down to ListFieldTHREE row, this row is "scrolled" into view in a very jumpy manner, no smooth scrolling. I know making the row height smaller will mitigate this issue, but I don't wan to go that way.
Main Question
How do I do smooth scrolling in a ListField?
There isn't an official API way of doing this, as far as I know, but it can probably be fudged through a clever use of NullField(Field.FOCUSABLE), which is how many custom BlackBerry UIs implement forced focus behavior.
One approach would be to derive each "list item" from a class that interlaces focusable NullFields with the visible contents of the list item itself -- this would essentially force the scrolling system to "jump" at smaller intervals rather than the large intervals dictated by the natural divisions between the list items, and would have the side benefit of not modifying the visible positioning of the contents of the list item.
Assuming you want the behavior that the user scrolls down 1 'click' of the trackball, and the next item is then highlighted but instead of an immediate scroll jump you get a smooth scroll to make the new item visible (like in Google's Gmail app for BlackBerry), you'll have to roll your own component.
The basic idea is to subclass VerticalFieldManager, then on a scroll (key off the moveFocus method) you have a separate Thread update a vertical position variable, and invalidate the manager multiple times.
The thread is necessary because if you think about it you're driving an animation off of a user event - the smooth scroll is really an animation on the BlackBerry, as it lasts longer than the event that triggered it.
I've been a bit vague on details, and this isn't a really easy thing to do, so hopefully this helps a bit.
unless you want to override the how the listfield paints or create your own wrapper, you will always have this issue, this is because each line is always visible when scrolling. Try using labelfield instead.

Categories

Resources