Questions tagged [android-linearlayout]

LinearLayout is one of the basic layouts in Android. It arranges its children one after the another, either horizontally or vertically.

LinearLayout is a view group that aligns all children in a single direction, vertically or horizontally. You can specify the layout direction with the android:orientation attribute.

All children of a LinearLayout are stacked one after the other, so a vertical list will only have one child per row, no matter how wide they are, and a horizontal list will only be one row high (the height of the tallest child, plus padding). A LinearLayout respects margins between children and the gravity (right, center, or left alignment) of each child. More information about the layout:

4954 questions
309
votes
16 answers

frequent issues arising in android view, Error parsing XML: unbound prefix

I have frequent problem in android view, Error parsing XML: unbound prefix on Line 2.
Pentium10
  • 204,586
  • 122
  • 423
  • 502
307
votes
24 answers

Is it possible to evenly distribute buttons across the width of a LinearLayout

I have a LinearLayout (oriented horizontally) that contains 3 buttons. I want the 3 buttons to have a fixed width and be evenly distributed across the width of the LinearLayout. I can manage this by setting the gravity of the LinearLayout to center…
yamspog
  • 18,173
  • 17
  • 63
  • 95
293
votes
10 answers

Android LinearLayout Gradient Background

I am having trouble applying a gradient background to a LinearLayout. This should be relatively simple from what I have read but it just doesn't seem to work. For reference sakes I am developing on 2.1-update1. header_bg.xml:
Genesis
  • 8,038
  • 3
  • 21
  • 22
287
votes
19 answers

Linear Layout and weight in Android

I always read about this funny weight value in the Android documentations. Now I want to try it for the first time but it isn't working at all. As I understand it from the documentations this layout:
Janusz
  • 187,060
  • 113
  • 301
  • 369
271
votes
10 answers

How do you make a LinearLayout scrollable?

I have lot of items on the screen and I need to use the scrollbar so the user can scroll down. However, the scroll is either not visible or it's not working. How is it possible to add a scrollbar to a LinearLayout?
Troj
  • 11,781
  • 12
  • 40
  • 49
218
votes
4 answers

How do I use a compound drawable instead of a LinearLayout that contains an ImageView and a TextView

Ran the new Lint tool against my code. It came up with a lot of good suggestions, but this one I cannot understand. This tag and its children can be replaced by one and a compound drawable Issue: Checks whether the current node can be replaced by…
207
votes
6 answers

How to center the content inside a linear layout?

I'm trying to center an ImageView inside a LinearLayout horizontally and vertically, but I just can't do it. The main reason why I'm not using a RelativeLayout for that is because I need the layout_weight (my Activity consists of four columns that…
horta
  • 2,292
  • 2
  • 14
  • 16
191
votes
5 answers

What are the differences between LinearLayout, RelativeLayout, and AbsoluteLayout?

I am confused about the difference between LinearLayout, RelativeLayout, and AbsoluteLayout. Could someone please tell me the exact differences between them?
179
votes
8 answers

Fit Image in ImageButton in Android

I have 6 ImageButton in my activity, I set images through my code in them ( not using xml). I want them to cover 75% of the button area. But where as some images cover less area, some are too big to fit into the imageButton. How to programatically…
Rohit
  • 6,941
  • 17
  • 58
  • 102
170
votes
14 answers

Android LinearLayout : Add border with shadow around a LinearLayout

I would like to create the same border of this LinearLayout as the example : In this example, we can see that the border is not the same all around the linearLayout. How can I create this using an XML drawable file? For now, I have only able to…
wawanopoulos
  • 9,614
  • 31
  • 111
  • 166
169
votes
4 answers

Android: How to Programmatically set the size of a Layout

As part of an Android App I am building a button set. The buttons are part of a nested set of LinearLayouts. Using weight I have the set resizing itself automatically based on the size of the containing parent LinearLayout. The idea is, based on the…
codingCat
  • 2,396
  • 4
  • 21
  • 27
163
votes
11 answers

Put buttons at bottom of screen with LinearLayout?

I have the following code, how do I make it so that the 3 buttons are at the bottom?
thedeepfield
  • 6,138
  • 25
  • 72
  • 107
151
votes
6 answers

Get all child views inside LinearLayout at once

I have a LinearLayout, which contains several child TextViews. How can I get child views of that LinerLayout using a loop?
Adham
  • 63,550
  • 98
  • 229
  • 344
145
votes
9 answers

How to add a TextView to LinearLayout in Android

I am trying to add TextViews to my xml-defined layout in code. I have a xml-sheet, where a lot of Views are defined. But I have to add some views in code, so a create a LinearLayout in the…
Martin
  • 1,571
  • 3
  • 10
  • 5
144
votes
10 answers

How can I create a border around an Android LinearLayout?

I have one big layout, and one smaller layout inside of it. How do I create a line border around the small layout?
user1302569
  • 7,131
  • 13
  • 46
  • 66
1
2 3
99 100