Creating a custom paginator indicator - java

I have a mock up that I want to create for when I'm switching between views in a viewpager.
The filled in circle would be indicative of a previous page, the semi-filled in circle would indicate current page and the last couple of empty circles would be the upcoming pages not currently viewing.
I was wondering where can I get started on how to create something like this?
I was also wondering how would I know how many pages are left to be viewed set that equal to the number of empty circles to show.
How would I be able to move along the circle images when swiping between views?
Thanks.

You dont need to reinvent the wheel for it so you can use library with little modificaiton in its source code.
use the library
https://github.com/JakeWharton/Android-ViewPagerIndicator
library have CirclePageIndicator which is performing the thing you need setting current circle as you scroll pages in ViewPager.you will need to add code to below class to drawPrevious circle in onDraw method.you can do that by storing previously selected page in variable and draw the previous page indicator as per your need.
https://github.com/JakeWharton/Android-ViewPagerIndicator/blob/master/library/src/com/viewpagerindicator/CirclePageIndicator.java

Related

Android Studio: Group elements together

I am fairly new to android studio and I am trying to make a car rental app for a university project.
I designed an app which has a horizontal slider containing blocks of different cars however I am unsure on how I would do this, I understand how the slider works and how to add elements to it.
I have a linear layout within the horizontal slider which will contain all of the blocks but I am unsure how to make a block of elements. Within the block it should have two buttons, an image and some text. Here is a picture of the design.
As you can see the available blocks are surrounded by a square. this is what I want, a small container which surrounds my data. Sort of like a div box in html.
Is there a way to do this?
Please just point me in the correct direction!
Many thanks!
It seems like cardviews can handle most of the grouping you want to do. I would reccomend looking into them because they incorporate a lot of material design components right out of the box.
https://developer.android.com/guide/topics/ui/layout/cardview

Android TextView OverLapping

I am trying to create a top bar for my app that shows the users level, coins. So i have an image view that displays the coin icon and a textview that displays the number of coins, if the number gets high it overlaps the image rather than pushing back the image and keeping everything aligned, is there a way to do that?
Without knowing your layout XML this is pure guesswork, but I'm assuming these two views are in a RelativeLayout. If so, add to one of them an attribute like this:
android:layout_toLeftOf="#id/otherViewId"
Options available are layout_toLeftOf layout_toRightOf layout_above and layout_below.
Post your layout XML and I'll update this with a better answer!
If you are using the relative layout then you can use the z-index attribute of views to manage the ordering.

random GridView with Images

I want to create a DayDream for my App and i want a Wall of images but i dont know how to randomize the images.
I want that some images are (2 times) bigger than other images and the other images are around them, all random. Is there a simple way to do this?
The Images are saved dynamically in a ArrayList of ImageViews before they will be loaded into the GridView.
Currently i have a simple Horizontal Layout which gets filled with ImageViews, but this is way too simple and won't fill the complete screen...
I have no point where i could start, any help would be fine!
I'm not sure that you can do that with a GridView. You're essentially looking to do a TableView and specify how many columns an item can take up. Alternatively, with some fiddling, you may be able to achieve what you want with a RelativeLayout.
For both TableView and RelativeLayout you'll have to write your own adapters to put the content in the views.
try http://www.androidviews.net/2013/01/quiltview-library/ or
http://www.androidviews.net/2013/01/pinterest-like-adapterview/
as far as i know quiltview is created randomly every time, so maybe u should go with that.

SMS Balloons / Long Chat Boxes

I want to be able to add a text-messaging balloon every time the user revives data from a HttpGet, I want it so that it looks nearly identical to the default Android text messaging UI. I'm fine with all the code, I just need a way to create the UI and create another text balloon every time data comes back from a HttpGet request.
Thanks ever so much, for the answering this questions and I'm sure there's an easy way to do it, yet I've found no way by using the 'ole Google.
I am doing something similar for my app am doing the following to achieve it:
You will need a 9-Patch-Image (a stretchable PNG, see here) that represents the bubble. You want to make the part stretchable that does not include the corners of the bubble. You can create the bubbles using an image editor of your choice (I'd recommend a vector graphics editor like Inkscape). Then use the 9-Patch editor included in the Android Developer Tools to transform the PNG image into a 9-Patch PNG.
Create a custom layout file for one bubble. Create a textview inside it, and add your bubble as a background resource. (android:background)
Use an arraylist with a custom adapter to inflate and fill your items.
So far, this will give you identical bubbles as background for all messages.
If you want to get fancy, you can create different bubbles for participants, and use the setBackgroundResource method in your Adapter to set the correct background.
Further, if you wish to align them left or right, like in the message app, you will need to add spacers to the left and right of your TextView in the layout file. I used FrameLayouts with a fixed width. Make sure to set their visibility to GONE.
As with swapping the different bubble colors, just set the visibility of the left/right spacer.

GUI, java, SWT and world map representation

I'm trying to implement a small-scale strategy, taking turns game
implemented in Java, GUI is made with JFace and SWT.
My challenge is to write a GUI implementation of the world map,
where countries will act as clickable buttons. However, countries
have no fixed boundaries, no rectangular shape, and simply no way
I can think of to be described in a grid layout.
This is my first time trying to implement a project of this type,
please advise
If it's a tile based map (like at Civilization) or it's displayed as pixmap, you could save the ownership of each tile/pixel in a two-dimensional array. Just display the map a a simple, clickable pixmap in a canvas an add a MouseListener. If you get a click event at the coordinates (X,Y), you can just get your country like:
Country clickedCountry = myCountriesOnMap[X][Y];
... in your Listener implementing the MouseListener interface. myCountriesOnMap would be of type Country[][].
Of course, you will need an algorithm that will resolve the ownership for each tile/pixel at startup or if a territory gets conquered (I don't know, if this may happen). May be you will have to define your countries as polygons (like you would do it for a HTML map). I cannot help you on this, as I haven't done anything similar jet, but I'm sure you will find something on Google.
Greetings
Sacher
Try to use the OpenStreetMap data. It contains exact country borders and good image export possibilities.
The Key:border tag will show you all borders. You could extract it and calculate your clickable areas.

Categories

Resources