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

How do I enforce a circular reference in a RelativeLayout?

I have two widgets within a RelativeLayout that must reference each other. Technically it is not a circular reference since the widget A is vertically aligned with widget B and widget B is horizontally aligned with widget A. Here is my code…
Barry Fruitman
  • 12,316
  • 13
  • 72
  • 135
13
votes
3 answers

ConstraintLayout Vs RelativeLayout & CardView - Cache and Memory space

I have developed an application that retrieves data from json to local database on mobile and displays it from local database with RecyclerView, and my container layout is like below :
13
votes
6 answers

Android Layout with ListView between a "top bar" and "bottom bar"

I'm trying to construct a layout where there is a text view at the top of the screen and a bottom bar at the bottom of the screen. Each of these views should stay fixed in place and in between the 2 should be a ListView. TOPBAR LISTVIEW…
13
votes
6 answers

How to get programmatically width and height of Relative - Linear layout in android?

I required runtime dimensions of Relative/Linear Layout. activity_home.xml:
Hiren Patel
  • 52,124
  • 21
  • 173
  • 151
13
votes
3 answers

Android align layout center

I`m trying to make Layout with LOGO and TEXT align center between ActionBar and Bottom layout. Like this I try to do it, but it does not work corectly. It make the layout with logo by center of the scree. It look like this Does the anybody know…
Volodymyr
  • 198
  • 1
  • 2
  • 12
13
votes
2 answers

Android's RelativeLayout seems broken

I'm working on a layout where I use a ListView with RelativeLayout line items. The lineitems themselves are not displaying correctly. The issue is that the txtVideoDuration TextView is drawn at the top of the line item instead of the bottom.…
Jeremy Edwards
  • 14,620
  • 17
  • 74
  • 99
13
votes
3 answers

How to center two views within a relative layout?

The task is simple: there are two buttons and a TextView above them. All the widgets shoud be centered within the relative layout. The only one idea I have is create the third widget View and use it as a center axis for the buttons. Any ideas? A…
Maksim Dmitriev
  • 5,985
  • 12
  • 73
  • 138
13
votes
14 answers

Moving from one activity to another Activity in Android

I want to move from one activity to another (using virtual device). When I click on button to move, My emulator ones a dialog box showing unfortunately SMS1 has stopped working (SMS1 is my app name). Can anybody help me in correcting my…
13
votes
3 answers

RelativeLayout Scrollable

I have tried many times to aligh the elements in my RelativeLayout but I dont get the result I expected that is: I'd like to align the first button to top right and then I have multiple Textview and I want all of them Scrollable, but when I insert…
Davis
  • 215
  • 1
  • 4
  • 11
12
votes
2 answers

android RelativeLayout, equal spacing?

I'm using Relative Layout to create a calculator screen, and i have a row of buttons labeled 1, 2, and 3. I want them evenly spaced, but i'm not sure how to do this with Relative Layout I'm used to using the android:layout_weight function in…
kleaver
  • 831
  • 2
  • 9
  • 17
12
votes
6 answers

Can't move any elements in Android Studio for RelativeLayout

I'm trying to add some buttons/textviews or any other components to my relativelayout. I can't place them anywhere but top left. However, if I edit XML code it works fine. Here is the screenshot of current status I already changed my layout to…
BurakS
  • 133
  • 1
  • 2
  • 6
12
votes
4 answers

android - RelativeLayout height to fill remaining space of CollapsingToolBarLayout

I have the following design where there is a CollapsingToolbarLayout on top and below there is a RelativeLayout: I want the RelativeLayout to fill the remaining space until bottom so I can center the content like this: I tried using match_parent…
12
votes
4 answers

Android TextView not selectable in CoordinatorLayout? (TextView does not support text selection. Selection cancelled)

This is the error I get: W/TextView: TextView does not support text selection. Selection cancelled. I am stunned, because other Textviews I have implemented before in a RelativeLayout have had text selectable when I have the property…
Zac
  • 695
  • 1
  • 11
  • 34
12
votes
4 answers

RelativeLayout and ViewStub inflation

I have the following layout.
AHTOH
  • 446
  • 4
  • 16
11
votes
2 answers

Relative Layout. Between 2 items

How can I position an item between 2 other items and align it in the center? (please see the red button in the picture above) - How can I position it between the "Center Button" and "Bottom Button"? Here is my relative layout code:
pleerock
  • 18,322
  • 16
  • 103
  • 128