Dynamically add imageViews in a circular layout in Android - android

I want to add imageViews dynamically in a circle like a round plate.
Android dose not provide a circular layout so please help me to create a circular layout..
Thanks in advance!

Just check this out , this link shows how to make view in circular shape... just imlement your image view in it ...
http://developer.samsung.com/android/samples-4
or you can do this by xml :
<LinearLayout orientation=vertical for whole screen>
<LinearLayout weight=1 gravity=center> <!--- Top --->
</LinearLayout>
<LinearLayout weight=1 orientation=horizontal> <!-- middle -->
<LinearLayout weight=1 gravity=left/>
<LinearLayout weight=1 gravity=right/>
</LinearLayout>
<LinearLayout weight=1> <!-- botton -->
<LinearLayout weight=1 gravity=center/>
<LinearLayout weight=1 gravity=center/>
</LinearLayout>
</LinearLayout>

You don't need a special layout for this.You can use a Relative Layout or a Frame Layout.
Just add the views dynamically in the normal way but position them using margin, padding etc so that they look like a circle.

From your question I can see that you need a circular layout on Android to arrange your images. I think this library will help you doing this. this library gives you the ability to add item, rotate them with animation. Check it out!

You can use HorizontalScrollView.

Related

Android Studio - change background image size

So, i wanted to put an image in background of my screen. My problem is that if i just add the image to "background" it will fill all the screen, and my image gets defaced. I could put as an ImageView, but the problem is that i have an expandableListView in the same screen, and i wanted the image to stay behind, as a background.
Any idea how to do this?
Can have 2 solutions: Put as an imagemView but behind the list. Or add as a background but resize it. How can i do it?
Here is what happened:
He is what happens if i put the image as an imageView:
Yes this is very easy to achieve with relative layouts
<RelativeLayout ... >
<ImageView ...
android:layout_alignParentTop="true"
android:scaleType="centerCrop“ />
<ListView ...
android:layout_alignParentTop="true“ />
</RelativeLayout>
With a relative layout z-index is decided by the order you declare the tags, so stuff towards the bottom of the xml is in front of stuff from closer to the top, when they are in the same position.
Use a FrameLayout (Inside FrameLayout view written on top will appear on top and so on)
<FrameLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
></ListView>
<ImageView
android:layout_width="your_width_in_dp"
android:layout_height="your_height_in_dp"
/>
</FrameLayout>
You can also place FrameLayout inside another layout.

listView inside of a linear layout with something else

i was just wondering if it was possible to have in one layout xml file, maybe a vertical linear layout at the top have a horizontal linearLayout and then below that (inside of the vertical layout) have a list view that takes up the rest of the screen?
I couldnt find any information specifically on this, and i'd like to know if its possible before i attempt it, thanks!
Give the ListView layout_height="0dp" and layout_weight="1". It will take up the remaining space not used buy the sibling LinearLayout.
<LinearLayout
android:layout_width:match_parent
android:layout_height:match_parent
android:orientation:vertical >
<LinearLayout
android:layout_width:match_parent
android:layout_height:wrap_content
android:orientation:norizontal >
<!-- other views --->
</LinearLayout>
<ListView
android:layout_width:match_parent
android:layout_height:0dp
android:layout_weight:1 />
</LinearLayout>

Layout Designing in android

can we design an footer like this(see the attached image), images in footer looks like popping out of one layout to another layout.
Could anybody let me know how to design like this and if possible some code examples.
thanks.
The best way to reuse the same layout around your application is to use the include directive. Something like this:
<include layout="#layout/my_footer" />
Where my_footer.xml is your footer layout.
In the detail you can achieve that layout using a simple LinearLayour horizontally oriented:
<LinearLayout android:orientation="horizontal">
<ImageButton android:layout_weight="1"/>
<ImageButton android:layout_weight="1"/>
<ImageButton android:layout_weight="1"/>
<ImageButton android:layout_weight="1"/>
<ImageButton android:layout_weight="1"/>
</LinearLayout>
You can find further information about reusing layout here: http://android-developers.blogspot.it/2009/02/android-layout-tricks-2-reusing-layouts.html
P.S. Note the attribute layout_weight which give the same width to all your LinearLayour child.
Let us assume the footer is footer-layout & footer-layout is under body-layout.
Now use a background image which will have 2 rows, the color of the first row must match with the color of body-layout, and the second row of the image will be black color.
Use this image as background of footer-layout & design it with ImageButtons as you want.
This will give you the above mentioned visual effects.

Android overlay outside/between layout boundaries

I have to add an overlay (ImageView) so that it's a bit shifted to the left of the containing layout's left boundary.
What is the best way to do this?
Tried something simple, like putting the ImageView inside the layout and use negative margin
android:layout_marginLeft="-20dip"
This made this:
(Correction: Text in the image should be 20dip not 20px)
AbsoluteLayout is deprecated. Is there something like z-order? Or what do I do?
Thanks in advance.
Edit: I tried using relative layout instead. Same effect. Here's the xml reduced to a minimum:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:clipChildren="false"
android:paddingLeft="50dip"
>
<ImageView
android:id="#+id/myId"
android:layout_width="60dip"
android:layout_height="60dip"
android:layout_marginLeft="-30dip"
android:clipChildren="false"
android:src="#drawable/pic" />
</RelativeLayout>
Result
Also happens when the containing layout has a background image smaller than the screen instead of padding.
Using RelativeLayout instead of LinearLayout (to allow overlapping) and adding this to the RelativeLayout fixed it:
android:clipToPadding="false"
set "android:clipChildren = false" in xml
Instead of
android:layout_marginLeft="-30dip"
try with
android:paddingLeft="-30dp"
Use a transparent(android:background="#00000000") imageview to the left of linear layout with width = 30dp. And make myId as aligning left in case of relative layout. If you are using linear layout make orientation as horizontal and let the transparent imageview be the first entry in it.

How to create android activity that shows at specified screen position?

My current layout displays activity that is not full screen (that's OK).
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="100dip"
android:layout_height="200dip" >
<TextView android:layout_height="wrap_content" android:id="#+id/textView1"
android:layout_width="fill_parent" android:text="#string/hello"></TextView>
I also added android:theme="#android:style/Theme.Translucent" to manifest for my activity.
My 200x100dip activity now shows in the upper left corner. How can i specify position of my linear layout (or my activity)?
You can use either FrameLayout or RelativeLayout as outer most layout for this. Ant then use absolute position in dp or android:layout_centerInParent or similar.
I believe your Activity´s outmost layout element (LinearLayout) will be placed in a FrameLayout that is the parent given from Android. I suggest you let your outmost layout match_parent/fill_parent in layout_height and _width and then center the content inside it with gravity="center" on your outmost layout. By letting the outmost layout being transparent and not catch click element it will appear as layout in the middle where elements behind is visible. If Im correct guessing that's what you want to achieve here.
put that layout in another absolute layout in which you use android:layout_width="fill_parent" and android:layout_height="fill_parent" the other thing you can do is to use this: http://www.droiddraw.org/
you can move your elements around manually with that and it will give you the XML code that is used to do that. I found it very useful in laying out XML in android.

Categories

Resources