In my layout there are three buttons and want to set PNG images for the buttons background but, the buttons overlap a little bit on one another. I want to how arrange the button in my layout. Which layout would be better for me in this context. You can see image of the layout below, that I want to develop. Please help me in this respect; your help would be cordially appreciated.
You could put all 3 buttons in a container, for example a RelativeLayout.
The center button (big one) would be aligned as "centerHorizontal=true". The left and right buttons would be aligned as "alignParentLeft=true", and respectively "alignParentRight=true". Plus, both buttons to have some margins on top.
I believe you can achieve the desired effect.
At least you can use AbstractLayout,although it is deprecated.
Related
So what I am trying to do is to have 2 invisible LinearLayouts with buttons they will be from the start to the screen.
On the onClick event one of them will appear with a translate animation,when the other is invisible and then on the other onClick event to close the open one and open the new one.
It will look similar to a sliding menu with the animation.
I want to know how the xml will look like in order to do that.
If it's possible with other layout (RelativeLayout), I also want to know.
Any tips on that?
There are multiple ways to achieve it.
Relative Layout definitely being the one as you your self know. :)
Add both the LinearLayouts with layout_width="match_parent" and layout_height="match_parent" and then toggle between them using setVisibility(View.GONE) and setVisibility(View.VISIBLE). Since View.GONE will remove one Linear Layout the other one will occupy the entire screen in its absence and vice versa.
You can also use FrameLayout. This by default places its children on top of each other.
Suit yourself. :)
Background:
I have an Activity that comprises four buttons that each take up a quarter of the screen.
It contains a horizontal LinearLayout that is divided in half by two vertical LinearLayouts as shown in the image below:
http://i.stack.imgur.com/P7Wd3.jpg
Desired Effect:
When I touch a button, I would like it to animate and fill up the entire screen.
Issue:
I have accomplished the animation aspect by changing X and Y scales from 1 to 2 onClick.
The problem is, however, that the animated button will not show when it leaves its parent LinearLayout.
Thoughts
I have tried making the non-animated buttons invisible, but the animated button will only show in its parent LinearLayout.
I know this problem would be solved if I had used a single LinearLayout, but I was unable to use the "layout:weight" feature to make each button take up half of both width and length.
So... How should I approach this issue?
I would appreciate any help :)
Try using a single RelativeLayout. Check this post for a nice example. You may have to setVisibility(View.INVISIBLE) for the other buttons.
Alternative:
Construct a RelativeLayout as above but put that as the only child
of a FrameLayout.
When animating a button, remove it from the RelativeLayout and add it to the FrameLayout specifying the gravity in the LayoutParams appropriately. This way the rest of the buttons will also be seen in the background during the animation.
I want to create layout having logo (small logo than screen) on the centre of the screen (horizontally & vertically) and on the top of the centred logo, I want to have a full screen (fill_parent) LinearLayout having ListView in it.
Want to keep ListView little transparent to keep my logo visible, looks like a watermark.
Can any one please tell me that what could be the XML for that?
for logo to be at centre use android:gravity="center" and also set opacity="translucent" and use it in a frame layout and also use overlay concept.
You can also check this other post.
Use Framelayout,
http://developer.android.com/guide/topics/ui/layout-objects.html
You can even use relative layout to overlap views.
I am confused with the appropriate layout design to be used for grid of buttons. I want to display a "textview and EditText" at the top. Below that there should be a 3*4 grid/matrix of 12 buttons(like cell phone keys), following another three linear buttons at the bottom of the root layout. (upper layout should not overlap the bottom buttons).
It would be of great help if anybody guide me in this regard.
UI layouts are done using xml files. Read about it before you start
While this is not exactly what you want here is a something to get you going.
Seeking help to design a layout as shown here:
http://docs.google.com/Doc?docid=0AQhgDtGvE2HgZGZ6cmtua185MTd0eGdyZmc&hl=en
The major challenge I face is aligning the components at desired positions. Please refer the three buttons(icons) and the way they are positioned.
Literally, going nuts, thinking how to position those exactly at the desired places.
Any help is much appreciated.
Regards,
Rony
Since you used the Android category, I'm assuming that you're trying to recreate this iPhone layout in Android.
The three buttons would probably be best laid as follows.
Your main layout container would probably be a RelativeLayout, so you can dock things to the top and bottom and lay everything else out in relation to one of its sibling elements. The three button icons (and I'm assuming you're referring to the circular buttons and not the tab bar buttons at the very bottom) would be in a LinearLayout centered within its parent (probably want to use gravity=center_horizontal on the main outer layout) and the individual items would have an equal left and right margin parameters to get the desired spacing (layout_marginLeft, layout_marginRight). You could also make the LinearLayout container of the buttons flush (layout_width=fill_parent) and using android:weight attribute on the outer buttons laying them out towards the center and using a lower weight on the center item. I'd favor the first option, personally.
If you're trying to create relatively complex layouts and any of the above doesn't make sense, go back and read the docs. Layout in Android is very powerful, but you really have to understand the available tools to take advantage of it.