Android layout: How would you try to achieve this? - android

The following layout should be achieved and displayed consistently on all screens (phone, tablet, phablet)
Landscape only
Top/left an imageview, always 16:9, probably covering
2/3rd of the width
Right of this a textview, 1/3rd width, full height
(well, maybe a little marigin at to bottom and top aligned with the
image view)
Two buttons on the bottom, left and right aligned
with the imageview.
Any pointer, how that could be achieved? I tried with sw320, sw480 and sw600 layouts, but there is always that one special device, on which the buttons overlap the image....

You can use constraint layout in this case. Constraint edges of all object with each other and edges of the object which is near to the edge, constraint it with layout edge. You can also find more information about this on android developer website or YouTube.

Related

How to put the right border of a View onto horizontal center?

In my Android app, I am using a RelativeLayout to custom one of my Activitys.
I have a square ImageView that I want to set precisely. In other words, I want its right border to touch the horizontal center of the layout.
Is such a thing possible without doing weird things such as centering and then marging?
It's not a perfect solution but potentially you could use:
android:layout_marginRight="xdp"
Where x is half of your screen width + half the width of your imageView?
I know it's not perfect but might help until some guru comes along

Android layout that crops rather than resize its children

I am looking for an android layout (if there exists) that can do the following.
2 images that occupies the entire width of the screen, stacked on top of each other. A slider say 2 or three pixels wide that allows a user to slide across the width of the screen revealing or hiding portions of the images.
Note that the layout like slidingPane does not work in this scenario as it resizes the contents in each pane rather than cropping them which is what I want.
To better describe the question here are some images.
Not really a layout, but achieves what I was after.
Added images to textureviews(1,2), added one of the textureviews(2) to a linearlayout. Added the texureView1 and linearlayout to a framelayout such that the linearlayout is on top. To achieve the above said effect the linearlayout and the textureView(2) that it holds is moved in opposite directions.

android layouts overlapping with changing sizes

I have a problem with a specific layout in Android.
What I want to achieve is approximately this:
http://imgur.com/xiN0u
The green area should always be visible at the bottom of the screen (size can change, but only marginally)
The red area should fill the rest of the screen on top.
The cyan area (inside the red layout) is a ScrollView and can change size and should not grow bigger than the space available
What happens is this: when the list expands, depending on the layout (i have tried linear, relative, mix of those,...), either the red or green area is overlapped with the other and is not accessible any more:
http://imgur.com/b7leA
I have tried this for a day now and whatever I do, some part of the layout is always overlapped. Is there a way to tell a ScrollView to only expand to a certain height? I know maxHeight doesn't exist. I highly appreciate every input as this is driving me crazy now! Is this possible at all with Android?

overlay imageview without pushing layouts down

a picture is worth a thousand words, so my question should basically be self-explanatory with the attached image: How to get rightmost screen instead of the center screen?
turns out i cannot attach images directly yet, so i have to link to it right now:
How to get rightmost screen instead of the center screen?
just to add, i realise that it is not really possible to have the framelayout NOT expand as shown in screen 2b, but my question remains as to how to achieve such an overlay without pushing the Other layouts down i.e. the bottom part of the imageview would be on top of the top right part of the other layouts
perhaps you could have the image you are dynamically adding be outside the frame layout. ie have a relative layout contain both framelayouts and the imageview – jkhouw1 1 hour ago

Positioning Android UI

Basically I'm developing a user interface similar to this:
http://ivitto.files.wordpress.com/2008/09/tap-tap-home.jpg?w=160&h=240
Where there are a series of buttons stored in a linear layout. My problem is at the moment they are centered along the x axis and the y axis so they are in the middle of the screen rather than in the lower half of the screen as in the image. The only way I can get what I want to work is by adding 100px or so "top padding" but of course the amount of pixels required is entirely variable on the screen resolution. Whilst this 100px is fine for a 480x320 screen it is far too small for a 1024x600 screen. So basically I'm asking how can I align my linear layout at the bottom of its parent (another linear layout)
Have you tried setting the gravity parameter of the linearlayout to bottom ?
Yes, try gravity bottom.
And by the way. You can use "dip" (density independent pixel ( http://developer.android.com/guide/practices/screens_support.html#density-independence ))instead of px for the padding. Although setting the gravity is surely the nicer way in this case...

Categories

Resources