Place view elements in circular manner using custom relative layout in Android - android

In android there are different type of Layouts LinearLayout will place the items Linearly(Horizontal/Vertical). Where RelativeLayout can do better and can place items relative to each other items.
By Overiding the RelaiveLayout I want to create a Layout which draw elements in circular manner (as shown in picture). I am able to do this using code snippet here http://developer.samsung.com/android/samples-4
But it is creating the whole layout from java code only, so if i need to make some complex layouts which have this circle as an element in the Layout, It will make me crazy becuase I have to write a lot of code.
I want to do it in a simpler way, so that I can use the same concept in XMLs layouts.
Can anyone who experts in Making custom layouts suggest me how can I achieve the same. I want something like, I have a layout file
And from java code i will get that CircleLayout using id and Set into an Object of CircleLayout class. Now there should be some functions written in CircleLayout class using them I can do the modification in Layout like
CircleLayout circle= (CircleLayout)findviewById(R.id.circle);
circle.setRadiusOfLargestRing(20);
circle.setNumberOfRings(6);
//Define any type of view form java
View v1 =new View(Context);
circle.setCenteralView(v1);
View v2 =new View(Context);
circle.addElementOnrings(ringNumber, v2)
..so on
I want maximum three rings, I have no problem if the rings formed from drawable resounce(like three rings already placed in drawable folder).
and then we can set listeners to each view inserted in to the ring.
My layout should be smart enough to place the views in the in ring in a way shown in picture .
I will be glad If someone can help me to develop a library so others also can take benefits of the same.
I am ready to write whole code if someone can guide me.

Related

Android how can I achieve a arrow based layout?

I want to know how is possible to achieve a arrow-based layout like this :
Any idea about what Layout is using this app in order to achieve that layout ? It seems like a kind of Staggered Grid Layout maybe ? Or maybe is using a library or a custom layout ? How can I achieve something similar ?
so here is how I would do something like this.
I make a bunch of custom views.
custom view #1:
PokemonView.
This is a regular Constraint Layout or CardView that contains all the items to show the pokemon, and its name, and all the other stuff.
custom view #2
EvolutionPokeminView.
this is a custom constraint layout that contains a PokemonView, and The Arrow ImageView (and TextView below), and helper methods to place the arrow in different directions.
for example:
setArrowDirection(int direction) \direction is some kind of enum for all directions (top, topLeft, topRight.. etc
another helper method is setArrorPosition,
setArrowPosition(int direction)
then you use the arrow direction method to set the correct arrow image into the arrowImageView, and you use the arrow position method to use ConstraintSet to programmatically set the correct position of the arrow in relation to the pokemon image.
after that, you prepare a few common layouts to use with different sets of data and populate them accordingly.
Things you'd need to know to make this approach work.
How to Make a Custom View in Android.
How to use ConstraintLayout effectively.
How to use ConstraintSet to programmatically edit ConstraintLayout constraints.

how to design dynamic ui in android like the image below

i am trying to design dynamic ui layout in android to present the date like the image below. i am **facing the challenges in the creating an view as clustered in the below mail **
i tried using list view!
but the each appeares in diffrent line, it dose not lookes like the image as below! is that possible to design like this. if so how to do that?
Try to create a few custom views, e.g. this circles with dates, this labels on the left and rights with xml layouts. Next, create parent view with some container layout, e.g. FrameLayout. In this parent view override it's onDraw() method, and there manually create and add every layout. It is simple, but might be not efficent, when there are many of views

Merging multiple views into a custom view

I could use some help with merging multiple views into one, like Pinterest has at
I know how to make a reusable custom view, been searching around custom components, compound controls, checked sdk samples and threads like Custom view made of multiple views , but it was never the proper way. I want it to also show 1 view (where i can set the image/texts dynamically) at the hierarchy viewer instead of 5+ child subviews, as that way increases performance aswell. I checked the github acc of Pinterest too without success :)
Can I somehow achieve it, or Im way too off? Thanks!
Try creating a separate layout.xml file containing all of the views you want to have in your custom view. Then in java all you would have to do is make reference to each of those custom views and fill them with your data.

Using Layout - Android

I have a layout, but I need put more views (Buttons, EditText, etc), but how you know, the layout of the ADT is a bit small and I can't to set more views or know where is it, Somebody know How can I set more of these?
Thank you
Android isn't like iOS how you can just position elements with drag & drop.
RelativeLayout will position elements relative to each other and LinearLayout will lay out elements sequentially in a linear fashion, either vertically or horizontally. Both methods are better executed by actually writing the View XML yourself.
I suggest reading this: http://developer.android.com/guide/topics/ui/declaring-layout.html
If you want to actually see what you are adding to your layout without messing with the XML you could maybe change the device that the renderer is using to preview your layout.
I don't know what IDE you're using but in Eclipse and Android Studio you can change the device that your layout preview is rendered on. That way you can see what you're adding as you add it.
Then just make sure to put everything in a scroll view so users can access all the views and widgets you've put in that layout for your activity or fragment or dialog or whatever else it is.

Graphical Layout shows first view of ViewFlipper, how to see others?

I am using Eclipse and a ViewFlipper. In Graphical Layout, I want to see the second, third, and forth layouts of my views - right now, I can only see the first view. Any suggestions?
If I'm understanding you correctly, you want to see each view in the 'Graphical layout' tool? The way I do this, is instead of having all the layout work done in one xml (where your viewflipper is) I make each view a new layout xml. And then have each view (xml file) included into the view flipper by using this....
<include
layout="#layout/layout_media"
android:id="#+id/flipper_media" />
Hope this helps.
just put each layout in relative layout or linear what ever you are working with then with each layout you will work with the first one in the order and etc.. then at the end put each layout in the order you want later
I had to subclass the ViewSwitcher class to display an indeterminate ProgressBar until data is ready to display in the second view. I used isInEditMode() to determine whether I was actually running the app or just previewing in AS.
You should be able to add a custom attribute to choose which child to display. This might look a bit overkill, but if you happen to already have to subclass your ViewSwitcher or ViewFlipper, i think it is not a big deal.
I will try to put an example later.

Categories

Resources