Questions tagged [android-relativelayout]

Android layout that displays child views in relative positions to each other or to the parent view.

RelativeLayout is a view group that displays child views in relative positions. The position of each view can be specified as relative to sibling elements (such as to the left-of or below another view) or in positions relative to the parent RelativeLayout area (such as aligned to the bottom, left or center).

RelativeLayout is a powerful utility for designing a user interface because it can eliminate nested view groups and keep your layout hierarchy flat, which improves performance. If you find yourself using several nested LinearLayout groups, you may be able to replace them with a single RelativeLayout.

This tag is to be used with more general or tags.

Useful links

3853 questions
9
votes
5 answers
9
votes
5 answers

TextViews on top and bottom, remaining space filled with ListView

I'm trying to put a TextView on top, another on bottom, and a ListView in between using the remaining space. However, my ListView is taking all the space to the bottom, making the last TextView to not even show up. The only way I can make it show up…
Pedro Moreira
  • 961
  • 1
  • 13
  • 28
9
votes
3 answers

Android - Two buttons in same line filling the whole width

I have a little problem defining a Relative Layout. I have a List View with scroll and two buttons always visible at the bottom of the list view. I just would like my two button have 50% of the width, filling the line. This is my code:
javifm
  • 705
  • 4
  • 9
  • 20
9
votes
2 answers

Android nested layouts

I am new to android layouts, Could please tell me how the performance of application when using nested layouts instead of using layout below, layout above, layout right, layout left attributes of relative layout for components. For…
mini
  • 855
  • 4
  • 15
  • 22
9
votes
3 answers

RelativeLayout inside LinearLayout?

I was wondering what I am doing wrong here, why does surrounding these buttons in a RelativeLayout cause an error? I haven't edited layouts much, can I not just stick in a Relative or Linear layout like that? If I don't surround the buttons in a…
Paul
  • 5,756
  • 6
  • 48
  • 78
9
votes
3 answers

How to wrap Image buttons in a horizontal linear layout?

Is there any way to wrap Image buttons in Horizontal Linear Layout? Or is there any other way to do the following thing? I have six image buttons. Suppose these buttons are appearing in a mid resolution device like this: Image button 1 | Image…
9
votes
2 answers

How can I make a `View` fill a `RelativeLayout`?

I have a RelativeLayout with some stuff in it, and I want a background view to fill the whole thing. This is what I would expect to work:
Timmmm
  • 88,195
  • 71
  • 364
  • 509
9
votes
3 answers

Android - set layout background programmatically

I have noticed that the setBackground method for the RelativeLayout object is targeted for API 16 (Android 4.1) and higher, but my application has the target API 8 and I cannot use it. Is there any alternative solution for this problem (besides …
9
votes
3 answers

Difference between Frame and Relative layout?

I'm new to android programming but from how much I have understood of the layouts from the documentation, RelativeLayout is mostly used when you need the views based on some rules and the FrameLayout when you want to overlap views. But unfortunately…
9
votes
4 answers

ImageView won't fill parent

I have a ScrollView on one of my screens. I want the right edge to have a shadow. I decided the easiest way to do this was to make the child of the ScrollView a RelativeLayout, and have two children of the RelativeLayout -- one being a…
Andrew
  • 20,756
  • 32
  • 99
  • 177
9
votes
7 answers

Android ListView fixed height item

Got a little problem. I'd like to create an android list view activity with all items in the list having a fixed height. So, my item layout (thread_item.xml) looks like this:
Dmitriy
  • 1,852
  • 4
  • 15
  • 33
9
votes
1 answer

Why is layout_marginBottom ignored when using wrap_content?

I have the following layout file:
dsafcdsge4rfdse
  • 260
  • 2
  • 12
9
votes
1 answer

Dynamically adding views to RelativeLayout inside ScrollView

I am trying to add dynamically created several RelativeLayouts into a LinearLayout which is inside a RelativeLayout, which is inside a ScrollView. When the total height of the all views exceed the size of the phone screen, all views are displayed…
ecem
  • 3,574
  • 3
  • 27
  • 40
8
votes
2 answers

RelativeLayout causes animation not to work?

I have an activity whose layout only contains a VideoView. Here is the xml:
FoamyGuy
  • 46,603
  • 18
  • 125
  • 156
8
votes
1 answer

Android - How do I specify weight programmatically for a RelativeLayout?

I want to do something like this programmatically - It does not let me do a setWeight programmatically. However, I do see…
Suchi
  • 9,989
  • 23
  • 68
  • 112