Questions tagged [layout]

The layout tag is for questions about the placement, alignment and justification of objects with respect to a containing element. For questions pertaining to CSS, use the 'css' tag instead.

In computing, layout is the process of calculating the position of objects in space subject to various constraints. This functionality can be part of an application or packaged as a reusable component or library.

Android Development Examples:

HTML Examples:

26721 questions
223
votes
12 answers

Set the layout weight of a TextView programmatically

I'm trying to dynamically create TableRow objects and add them to a TableLayout. The TableRow objects has 2 items, a TextView and a CheckBox. The TextView items need to have their layout weight set to 1 to push the CheckBox items to the far right. I…
eugene
  • 2,519
  • 3
  • 17
  • 5
218
votes
12 answers

How to make layout with View fill the remaining space?

I'm designing my application UI. I need a layout looks like this: (< and > are Buttons). The problem is, I don't know how to make sure the TextView will fill the remaining space, with two buttons have fixed size. If I use fill_parent for Text View,…
Luke Vo
  • 17,859
  • 21
  • 105
  • 181
218
votes
20 answers

Are fluid websites worth making anymore?

I'm making a website now and I am trying to decide if I should make it fluid or not. Fixed width websites are much easier to make and also much easier to make them appear consistent. To be honest though, I personally prefer looking at fluid websites…
Adam
  • 2,606
  • 4
  • 19
  • 14
214
votes
13 answers

Algorithm to implement a word cloud like Wordle

Context Take a look at Wordle: http://www.wordle.net/ It's much better looking than any other word cloud generators I've seen Note: the source is not available - read the FAQ: http://www.wordle.net/faq#code My Questions Is there an algorithm…
namenlos
  • 5,111
  • 10
  • 38
  • 38
213
votes
6 answers

Truncating long strings with CSS: feasible yet?

Is there any good way of truncating text with plain HTML and CSS, so that dynamic content can fit in a fixed-width-and-height layout? I've been truncating server-side by logical width (i.e. a blindly-guessed number of characters), but since a 'w' is…
Sam Stokes
  • 14,617
  • 7
  • 36
  • 33
213
votes
16 answers

How to retrieve the dimensions of a view?

I have a view made up of TableLayout, TableRow and TextView. I want it to look like a grid. I need to get the height and width of this grid. The methods getHeight() and getWidth() always return 0. This happens when I format the grid dynamically…
greenset
212
votes
15 answers

How can I get the height of a widget?

I don't understand how LayoutBuilder is used to get the height of a widget. I need to display the list of Widgets and get their height, so I can compute some special scroll effects. I am developing a package and other developers provide a widget (I…
JoKr
  • 4,976
  • 8
  • 27
  • 39
205
votes
9 answers

How to make an inline-block element fill the remainder of the line?

Is such a thing possible using CSS and two inline-block (or whatever) DIV tags instead of using a table? The table version is this (borders added so you can see it):
Triynko
  • 18,766
  • 21
  • 107
  • 173
205
votes
18 answers

Android: why is there no maxHeight for a View?

View's have a minHeight but somehow are lacking a maxHeight: What I'm trying to achieve is having some items (views) filling up a ScrollView. When there are 1..3 items I want to display them directly. Meaning the ScrollView has the height of either…
znq
  • 44,613
  • 41
  • 116
  • 144
204
votes
4 answers

Change the Right Margin of a View Programmatically?

Can this attribute be changed dynamically in Java code? android:layout_marginRight I have a TextView, that has to change its position some pixels to the left dynamically. How to do it programmatically?
NullPointerException
  • 36,107
  • 79
  • 222
  • 382
196
votes
7 answers

Fixed Table Cell Width

A lot of people still use tables to layout controls, data etc. - one example of this is the popular jqGrid. However, there is some magic happening that I cant seem to fathom (its tables for crying out loud, how much magic could there possibly…
Jimbo
  • 22,379
  • 42
  • 117
  • 159
195
votes
8 answers

Set the absolute position of a view

Is it possible to set the absolute position of a view in Android? (I know that there is an AbsoluteLayout, but it's deprecated...) For example, if I have a 240x320px screen, how could I add an ImageView which is 20x20px such that its center is at…
Sephy
  • 50,022
  • 30
  • 123
  • 131
194
votes
18 answers

How to force an entire layout View refresh?

I want to force the main layout resource view to redraw / refresh, in say the Activity.onResume() method. How can I do this ? By main layout view, I mean the one ('R.layout.mainscreen' below) that is called in my Activity.onCreate(), like…
MickeyR
  • 1,858
  • 2
  • 13
  • 24
192
votes
11 answers

Can you center a Button in RelativeLayout?

I'm trying to center a button in relative layout, is this possible? I've tried the Gravity and Orientation functions but they don't do anything.
Arcadia
  • 2,007
  • 2
  • 14
  • 10
182
votes
3 answers

What is the difference between Xamarin.Form's LayoutOptions, especially Fill and Expand?

In Xamarin.Forms every View has the two properties HorizontalOptions and VerticalOptions. Both are of type LayoutOptions and can have one of the following…
Falko
  • 17,076
  • 13
  • 60
  • 105