Questions tagged [android-layoutparams]

The base LayoutParams class just describes how big the view wants to be for both width and height. For each dimension, it can specify one of:

  • FILL_PARENT (renamed MATCH_PARENT in API Level 8 and higher), which means that the view wants to be as big as its parent (minus padding)
  • WRAP_CONTENT, which means that the view wants to be just big enough to enclose its content (plus padding) an exact number

There are subclasses of LayoutParams for different subclasses of ViewGroup. For example, AbsoluteLayout has its own subclass of LayoutParams which adds an X and Y value.

Useful links

113 questions
290
votes
4 answers

How to programmatically set the layout_align_parent_right attribute of a Button in Relative Layout?

I have a relative layout which I am creating programmatically: RelativeLayout layout = new RelativeLayout( this ); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, …
Fahad Ali
  • 2,903
  • 2
  • 13
  • 4
78
votes
15 answers

Unknown attribute android:layout_width, layout_height, id, gravity, layout_gravity, padding

Getting Unknown attribute error on all android tag. In layout XML, Auto suggestion is not showing all attributes (like layout_width, layout_height, orientation, orientation & all others android attributes.) Here is a Snap shot Things i have…
61
votes
3 answers

Removing/Adding constraint programmatically in ConstraintLayout

I want to remove and add constraint programmatically based on some condition. Here are the screenshots: and I want to remove it like this but in code: so the same effect in want to achieve programmatically and here is the code that I tried: if…
19
votes
6 answers

Android: permission denied for window type 2038 using TYPE_APPLICATION_OVERLAY

I trying to create a view that is above other applications: WindowManager.LayoutParams paramsDirectorView = new WindowManager.LayoutParams( WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT, …
Derwrecked
  • 591
  • 1
  • 5
  • 13
16
votes
3 answers

Setting margin programmatically to CardView

I have a CardView in my XML layout and I need to set margins to it programmatically (This is because I don't need margin at all times. Based on few conditions, I either set or remove the margin). Here's how I did it: CardView.LayoutParams…
14
votes
1 answer

How to set layout_alignParentRight="false" programmatically?

How to set android:layout_alignParentRight="false" programmatically? I can set it to true by this code but I want to set it to false programmatically: RelativeLayout.Layoutparams params…
812621
  • 773
  • 1
  • 6
  • 20
12
votes
4 answers

Cannot resize linear layout children in android react native module

Full code here Video of correct behavior in java and incorrect in react native here I have modified a linear layout to respond to touch by resizing the left child while the right child takes up the rest of the space, simulating a horizontal scroll…
sbaar
  • 1,412
  • 1
  • 16
  • 32
10
votes
1 answer

How to programmatically access the current constraints of views in a ConstraintLayout?

I can programmatically modify constraints of a view in a ConstraintLayout using ConstraintSet but before applying modifications, I want to test that it hasn't been done already. To do this I need to programmatically access the current constraints of…
6
votes
2 answers

How to set background of collapsing toolbar with custom behavior to fit whole screen

I'm following nice repo which shows how to make custom behavior of collapsing toolbar WhatsApp-ProfileCollapsingToolbar. What I don't like is when picture below toolbar (toolbar's font is white) is white then toolbar is not visible. So I'm trying to…
6
votes
0 answers

Android Windows: When and how are they created?

I have read the standard Windows-related documentation and pawed through a bunch of the source code in an attempt to understand how and when Android Windows are created. I believe I have my arms around it and would like to have it verified or…
Barry Holroyd
  • 955
  • 1
  • 8
  • 20
5
votes
1 answer

Changing LayoutParams of always visible Chat Heads to not always visible

I am attempting to add a view I am generating via a service. The code I am using is based on Facebook Chatheads which are always visible, regardless of the apps state. They are also displayed above anything else too: I now wish to constrain the…
Z101
  • 647
  • 1
  • 7
  • 25
5
votes
2 answers

Picasso .fit().centerCrop() not working with WRAP_CONTENT

I have an ImageView that I create programmatically, and load an image into using Picasso. The height and width of the ImageView are set to WRAP_CONTENT. The image is pretty large, so I want to use Picasso's .fit().centerCrop() methods in order to…
4
votes
0 answers

How can 'keyline' LayoutParams of CoordinatorLayout be used?

According to the documentation: The index of the horizontal keyline specified to the parent CoordinatorLayout that this child should align relative to. Can anyone explain how the 'keyline' works with an example?
4
votes
2 answers

Horizontal android:animateLayoutChanges="true" Animation not smooth

I have a layout that animate as below The txt_billion is shown dynamically, with android:animateLayoutChanges="true" (Layout code below). Notice the Hundred is jumping (actually all are jumping, but the Hundred is just more obvious). How to prevent…
4
votes
0 answers

How to change the z-order of window added via WindowManager?

Is it possible to specify the z-order of each window ? in the image below each editText are in their own window added via WindowManager. as you can see i have a z-order problem like you see on the picture, the last window added seam to take the…
1
2 3 4 5 6 7 8