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
17
votes
2 answers

Set RelativeLayout child to fill unused space

I have this layout:
artem
  • 16,382
  • 34
  • 113
  • 189
16
votes
2 answers

Android Problems Converting ViewGroup with Children into Bitmap

I'm successfully converting a ViewGroup (RelativeLayout) into Bitmap using a Canvas. However, when the draw happens I only see the ViewGroup with its background drawable and not its children (two TextViews) who should be laid out within the…
Rob Holmes
  • 3,768
  • 1
  • 16
  • 19
16
votes
3 answers

Relative Layout alignParentLeft vs alignParentStart

So I am comfortable with using relative layouts, but whilst getting used to Android Studio I noticed that in my relative layout child views it generated both of the…
Andrew S
  • 2,847
  • 3
  • 33
  • 50
16
votes
4 answers

RelativeLayout gravity center not working

I'm trying to horizontally center several views in a RelativeLayout that is a base.
Frank Sposaro
  • 8,511
  • 4
  • 43
  • 64
15
votes
7 answers

Android: Using alignBaseline for an image following text

Below is a TextView followed by an ImageView contained in RelativeLayout. I'm trying to get the bottom of the image to align with the baseline of the text. When I use alignBaseline for the image,reference the TextView, it is the top of the image…
15
votes
4 answers

Android: Setting Background Image for RelativeLayout?

I have downloaded an image at runtime. Now I want to set it as a background for RelativeLayout. Does it possible?
Vivek
  • 4,170
  • 6
  • 36
  • 50
15
votes
2 answers

Picasso Does Not Preserve Aspect Ratio While Resizing Image

I'd like to preserve the aspect ratio of an imageView and resize it to fill / fit as large as possible without distorting/changing it's aspect ratio using Picasso. Thus far I've found this: scaling image size in Picasso which suggests using: …
15
votes
3 answers

Set the width of relativelayout 1/3 the width of the screen?

I have a layout like below. Now, I don't want to set the width of relative layout to fixed 240 dp. I want to set the width of the relative layout to 1/3 the width of the screen. Is it possible to do that in the xml file. If it is impossible, how can…
Kelvin Tan
  • 982
  • 1
  • 12
  • 33
15
votes
1 answer

How can I align an element to be in center of and above another element in relative layout?

Here's a picture so you can understand what I want: I have this green element already set up in my relative layout, and what I want is to put another element (the black one in the pic) above it so it gets centered exactly in the middle of the green…
15
votes
5 answers

Android RelativeLayout Selector state_pressed doesn't work

I have RelativeLayout like this:
Maxim Shoustin
  • 77,483
  • 27
  • 203
  • 225
14
votes
4 answers

RelativeLayout - Scroll down

I have the following layout:
John Smith
  • 808
  • 3
  • 9
  • 20
14
votes
3 answers

Add RelativeLayout with buttons below RecyclerView

I need to add a RelativeLayout below my RecyclerView and was able to do so, except that the button under TOTAL(R.id.total_amount_tv) does not show: I can easily scroll through the items and it doesn't affect my RelativeLayout. I just need the…
14
votes
5 answers

Ripple effect does not work in RelativeLayout

I'm trying to implement ripple effect in a RelativeLayout on API 22 but it doesn't show up. However the same ripple works in a Button. The code for my ripple drawable is as follows:
Varun Kumar
  • 1,241
  • 1
  • 9
  • 18
14
votes
1 answer

How to set layout_alignParentRight="false" programmatically?

How to set android:layout_alignParentRight="false" programmatically? I can set it to true by this code but I want to set it to false programmatically: RelativeLayout.Layoutparams params…
812621
  • 773
  • 2
  • 6
  • 20
13
votes
5 answers

OnClickListener doesn't work with clickable attribute

So, my problem is that OnClickListener doesn't work when I set android:clickable="true" into my class. This is MyClass xml code:
Scit
  • 1,722
  • 4
  • 15
  • 18