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
1
vote
2 answers

fit size of parent layout

I have a simple linear layout and want to divide the screen into two equally sized parts. In the upper one, I want to put a SurfaceView that has exactly the same size as its parent, i.e. half of the screen. Unfortunately, it always either takes all…
1
vote
1 answer

Linearlayout getHeight() return 0 but inside setOnClickListener return true value

Edit: Meant to ask "Why does it work inside setOnClickListener", but found it shortly after. https://stackoverflow.com/a/21926714/6474462 Old: Was playing with the ObjectAnimator and noticed the LinearLayout getHeight() return 0, but inside the…
ChamTT
  • 41
  • 1
  • 3
1
vote
2 answers

How to know how much time take for loading layout in android?

I want to check which layout is loading fast with the same design like Relative Layout, Linear Layout or Constraint Layout but I can't get any tool or any idea about that so please help me out for my query. Thanks in Advance.
1
vote
1 answer

Align 2 images right in linear layout

I want to align 2 images in right side in linear layout.How to add space between 2 images? Here is my code. Vechile.xml
rakesh
  • 69
  • 2
  • 9
1
vote
1 answer

LinearLayout not getting clicked

I tried a lot but, my Linearlayout as below not getting clicked :
1
vote
2 answers

How to get even spacing between TextView in ConstraintLayout?

I got this issue here, which is easily fixed if I would use nested linearlayout like this:
1
vote
1 answer

Linear Layout Constraints added automatically when switching tabs

Android Studio keeps changing my constrains when switching tabs between Design and Text tabs. Before changing to Design tab:
Idan
  • 5,405
  • 7
  • 35
  • 52
1
vote
1 answer

android visiblity - reserve space of image view

I want android:visibility to resolve in xml layout based on a boolean returned. like android:visibility="card.isPrimary() ? 1 : 0". Android documentation says visible, invisible and gone are ints 0,1,2. My understanding is true/1 would resolve to…
Rk R Bairi
  • 1,289
  • 7
  • 15
  • 39
1
vote
1 answer

LinearLayout addview() disables margin on first child

I'm having a problem with adding views dynamically to LinearLayout. I'm trying to inflate cardViews from xml. I'm adding 4 CardViews and the every view is OK except the first which have no margins. I have no idea why. (picture…
1
vote
5 answers

Linear Layout - fixed height children are wrongly placed

I'm placing 3 TextView in a LinearLayout and want them to be equaly distributed AND to have a fixed height. The combination of layout_weight and a fixed layout_height should make sure, that all 3 views are always shown in one line and are always of…
prom85
  • 16,896
  • 17
  • 122
  • 242
1
vote
2 answers

Using LinearLayout to display a variable number of images

In a LinearLayout, I am trying to display an integer number using images for digits. I want the number to be centered and the images to scale depending on how many digits are present. My initial layout with 2 digits:
Chris C.
  • 959
  • 1
  • 8
  • 17
1
vote
1 answer

AdWhirl eats up all space of listview

I've an Activity with a vertical linearlayout containing images, buttons, listview and adwhirllayout. All have for their height wrap_content and the listview has weight="1" to force it to use all remaining space. This works fine as long as the…
Tin
  • 699
  • 1
  • 6
  • 19
1
vote
2 answers

LinearLayout setBackgroundDrawable bitmap from url

I am trying to set a background image from URL to a linear layout with bitmap but the method BackgroundDrawable() is deprecated and i cannot find any alternative for it. private LinearLayout linearLayout; linearLayout = (LinearLayout)…
Citrix
  • 257
  • 4
  • 14
1
vote
3 answers

Add Linear Layout Dynamically inside the List item?

I am not able to use List within the list so i jump to add the Dynamic Linear Layout to be Added inside the ListItems.I want to show the list which contains many textview and below the textview i want to display Another listview.So i switch to add…
Suman
  • 43
  • 11