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
141
votes
16 answers

Software keyboard resizes background image on Android

Whenever the software keyboard appears, it resizes the background image. Refer to the screenshot below: As you can see, the background is sort of squeezed. Anyone can shed a light on why the background resizes? My Layout is as…
Andreas Wong
  • 59,630
  • 19
  • 106
  • 123
125
votes
7 answers

How can I show ellipses on my TextView if it is greater than the 1 line?

I have the following Layout which does not work:
Sheehan Alam
  • 60,111
  • 124
  • 355
  • 556
118
votes
5 answers

Android - Center TextView Horizontally in LinearLayout

I have the following basic layout
Jake Wilson
  • 88,616
  • 93
  • 252
  • 370
116
votes
5 answers

Is a RelativeLayout more expensive than a LinearLayout?

I've always been using RelativeLayout everytime I needed a View container, because of it's flexibility, even if I just wanted to display something really simple. Is it ok to do so, or should I try using a LinearLayout when I can, from a…
103
votes
21 answers

How to group RadioButton from different LinearLayouts?

I was wondering if is possible to group each single RadioButton in a unique RadioGroup maintaining the same structure. My structure look like…
marcoqf73
  • 1,306
  • 3
  • 14
  • 18
99
votes
11 answers

How to add (vertical) divider to a horizontal LinearLayout?

I'm trying to add a divider to a horizontal linear layout but am getting nowhere. The divider just doesn't show. I am a total newbie with Android. This is my layout XML:
Ahmed-Anas
  • 5,471
  • 9
  • 50
  • 72
97
votes
6 answers

Layout orientation in code

I have this code in my application: LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT); and I just want to set the orientation of the LinearLayout to vertical. The equivalent in XML…
grgvn
  • 1,309
  • 1
  • 12
  • 25
83
votes
9 answers

Android Linear Layout - How to Keep Element At Bottom Of View?

I have a TextView which I want to pin at the bottom of a landscape activity that is using LinearLayout with vertically arranged elements. I have set android:gravity="bottom" on the text view, but it still likes to be just below the last element of…
Androider
  • 21,125
  • 36
  • 99
  • 158
79
votes
13 answers

How to show shadow around the linearlayout in Android?

How can I show shadow for my linear layout. I want white colored rounded background with shadow around the linearlayout. I have done this so far.
Santhosh
  • 4,956
  • 12
  • 62
  • 90
78
votes
2 answers

Remove all items inside linearlayout

I create a linearlayout that refes to an xml item. Inside this linearlayout i put some textview dynamically, so without taking them from the xml. Now i need to remove these textviews from the linearlayout. I tried this: if(((LinearLayout)…
pindol
  • 2,110
  • 6
  • 35
  • 52
77
votes
15 answers

onClick not triggered on LinearLayout with child

I've got a custom LinearLayout with a smaller TextView child. I'd like to be able to click the area not covered by the TextView, so I set clickable=true and an onclicklistener to the LinearLayout, but onClick is not triggered. If I set the onclick…
jul
  • 36,404
  • 64
  • 191
  • 318
73
votes
6 answers

How to add a TextView to a LinearLayout dynamically in Android?

I try to add a TextView to a LinearLayout dynamically such as in the following code, but it doesn't appear when I run the application? setContentView(R.layout.advanced); m_vwJokeLayout=(LinearLayout)…
Adham
  • 63,550
  • 98
  • 229
  • 344
71
votes
7 answers

Getting child elements from LinearLayout

Is there a way to obtain a child element of a LinearLayout? My code returns a view (linearlayout), but I need to get access to specific elements inside of the layout. Any suggestions? (Yes, I know I could use findViewById, but I am creating the…
Cody
  • 8,686
  • 18
  • 71
  • 126
71
votes
2 answers

LinearLayout vs RelativeLayout

What are the advantages of RelativeLayout over LinearLayout in android ? For a particular design which one would you prefer and what's the reason behind of that ?? Is it(RelativeLayout) comparable or similar like HTML
??
67
votes
4 answers

How to add border around linear layout except at the bottom?

How to add border around linear layout except at the bottom ? LinearLayout needs to have border at left, top and right side but not at the bottom.
Damir
  • 54,277
  • 94
  • 246
  • 365