Android Studio: Range Slider with three different 'bin' colours - android

I'm looking for something equivalent to MultiSlider's different colours for each bin feature but in the modern 'Materials Range Slider'.
MultiSlider's example:
MultiSlider's example
(from https://github.com/apptik/MultiSlider)
However Multislider is no longer being maintained as of 2 years ago and I don't want to depend on unmaintained code.
I've looked at the xml attributes for the Range Slider and I don't see something that would accomplish this. (https://developer.android.com/reference/com/google/android/material/slider/RangeSlider)
Context: I have three percentage based inputs that are user defined. A range slider seemed to be the most efficient way of dealing with having these three percentages defined nicely (without worrying about rounding, having it all equal to 100%, dealing with users typing in stuff, etc).
Is there a better way of dealing with three percentage based inputs then range sliders? If so, what is it?
If not, is it possible to implement this idea with range sliders?
If not, what third party libraries would you recommend?
Thanks in advance.
(It looks like this question comes closest, but if there is another solution besides 'make it yourself', that would be great, and if not, I'll make it myself then: Circular Progress bar with three different color in Android)
What I've tried:
Using Multislider: couldn't get it to build properly
Using Range Slider: can't seem to modify the colour of only one side of the track. There seems to only be 'active' track and 'inactive' track.

Related

Create transparent form

I work with FireMonkey in C++Builder, and I'm trying to make a transparent form, so that the components that are on it are displayed, but in the space where there are no components you can see what is below the form (transparent)...
I have set the Transparency property of the form to true, but the areas of the form that should be transparent look BLACK.
I have searched the Internet and found solutions for Delphi, but none for C++.
I tried to include this in the manifest:
SetActivityAttribute(MYFormTransparent ,android:theme, #android:style/Theme.Translucent.NoTitleBar)
but still, the same issue.
Any ideas?
This is a known problem that was introduced in 10.3 Rio. It has already been reported to Embarcadero (unfortunately, it has been closed as "works as expected"):
RSP-22314: Transparency Property
Marco Cantu commented on that report:
Sorry for not commenting sooner. We have done some research on it for the last update, but decided to defer a fix.
The core issue (in short) is that we use Android SurfaceView and this is a limitation of that platform control (only 2 SurfaceView instances are available). We are using this platform element as it allows us to mix styled and platforms controls (a feature we introduced in 10.30). By chancing the internal implementation, the transparency become unavailable.
There is an alternative implementation of forms via TextureView, but so far our tests have shown that the speed of rendering 2 times slower, and we don't want to slow down all FMX applications on Android for this feature.
There are some workarounds, one of them is to use a frame instead of a form. It works perfectly with transparency and uses less resources than separate form.
For existing code the fast way is to add a Layout to the form and have the controls inside it. When you need to display the form with transparency you can just move Layout from the specific form to main form as a child and align it on content Align = Content.
Other commenters noted:
I tested an alternative with formStyle = popup and stylelookup = popupboxstyle
with a rectangle in the form with transparency = 0.4 and some instructions to size the form with setBounds
The result is acceptable
As said by Herve Escriou, a work around is to set your formstyle property of the form to "Popup". This will make the form transparent again. But this wil have the effect of the wsMaximized style not working properly. You can go around this by making the following code additions to your form: ...

Xamarin Grid of Buttons or DataGrid for Generating a Playing Field for Numbers Based Game

I'm building a numbers based game similar to sudoku on Xamarin. I'm targetting both Android and iPhone, however, focusing on Android first. I've seen the SF Datagrid, and I've also seen the licensing price for that, but I've also seen some Unity tutorials that simply have a two-dimensional array of buttons. For Xamarin, targetting both iOS and Android, would a field of buttons plus an additional 10 buttons on the bottom for the input of the digits 0-9 be ok, or would a data table of some sort be more efficient and easier to code? I don't know if the table will be a 4x4, 6x6, 8x8, 10x10, 12x12, 14x14, or 16x16 until the game or "puzzle" is being generated.
Normally, there will be some options to select the level of the game, then based on the selected grade,we can determine whether the table is 4x4, 6x6, 8x8, 10x10, 12x12, 14x14, or 16x16.
For the table,we have many methods to achieve this, a simple method is to use Grid .
And there is a sample ,you can check it out here. It might help you.

Issues designing Android UI in Xamarin

I am in the process of writing my first android app. I figured, for a simple exercise, I'd write an app to keep score in bowling.
I want to create a picture of the pins, with a touch toggling a pin between standing, and fallen. Then an ok button, that completes the shot. After each shot is entered, have a picture of the score updated.
Then, I want to be able to click on a frame, and edit it...mistakes happen.
This seemed simple enough. At least if I were to whip up something in HTML5 I would be done by now.
However, I'm struggling with just drawing the UI...ugh.
Would I just create the pins as image buttons? And how do I align them properly...I can't seem to drag stuff where I want, it's all left aligned and stacked. Nothing like it should look.
And how can I dynamically create images for buttons? At least that's how I was thinking I would do the score (showing all 10 frames with the shots and running score.
I realize this is a beginner question. But I've been at it for five hours, and I'm no farther along.
I don't think it's necessarily fair to compare your speed in a dev environment you are new to with one you already know - you are bound to be slower in the new one.
To get more familiar with android's XML layouts, I recommend you take a look through some of the tutorials on layouts - on linearlayout, gridlayout, relativelayout, etc which I think will have you quickly working in XML to generate your ui.
One such tutorial is http://slodge.blogspot.co.uk/2013/01/an-mono-for-android-wrappanelflowlayout.html
Once you've learnt a bit about the XML, I suspect you'll also find the designer easier too.
For the questions about the pins, well these sound a lot like checkboxes, only drawn differently - so check out:
Custom checkbox image android
http://vimaltuts.com/android-tutorial-for-beginners/android-custom-checkbox

How would I go about this?(Android Whack-A-Mole Project)

I'm making a simple whack-a-mole game as my first mini-project for android. I'm not sure how to go about this. I know the basics of setting everything up and such but I'm not sure how to animate the moles and make it so that when the mole is in the up position it can be tapped and a point will be counted. I know I can do an image button and have a counter go up(counter++) but I need to be able to switch frames from the mole in the hole to the mole in the up position. Anyone have an idea as to how to do this? Thanks!
Android allows you to animate objects in a variety of ways. If you only need 2 images to switch, like a button with 'pushed' / 'not pushed' states, you can use a special type of Drawable called a selector (which allows you to specify different drawables for the various states of the target).
If you need more than two images, you may want to use the simple View animation that Android allows you to create using xml. For instance, you can create an xml animation that specifies an image to move/rotate/scale from one initial position to another, creating the in-between frames for you.
Android also has a newer, more complex and full-featured form of animation (which you probably don't need to go into).
Both of these animation systems are detailed at :
http://developer.android.com/guide/topics/graphics/animation.html
Otherwise you will need to create a series of images that you iterate through at a steady pace (which is the fundamental idea behind animation).
I've already made this before, I'll give you an overview, just check my post here: Simple Whack a Mole overview

implement minimumfontsize in android

I am trying to implement the minimumfontsize property in android. This is common to the ios sdk. Since it is not presently available in android I was wondering if anyone can help me with a similar implementation in android?
To be more specific, I am trying to implement this property for the TextViewUI in android.Hence I basically need to implement it for this widget.
These are the ios specs of this feature:
"When drawing text that might not fit within the bounding rectangle of the label, you can use this property to prevent the receiver from reducing the font size to the point where it is no longer legible.
The default value for this property is 0.0. If you enable font adjustment for the label, you should always increase this value. This property is effective only when the numberOfLines property is set to 1."
Without knowing what you intend to do with the code, there isn't much help to be had. The closest thing to what you describe in android is setting device independent pixels (android:textSize="30dp"), which ensure that however big (or small) the text looks on your handset, it will look pretty much just like that on all other handsets, at least those of the same size/density. See R.attr and Supporting Multiple Screens

Categories

Resources