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

123 questions
5
votes
2 answers

Android: ViewGroup.MarginLayoutParams not working

I used this to set the margin programmatically, but it does not work, the margins are not applied. In the constructor: public TimeWindow(Context context, int pixels, int left, int top){ super(context); ViewGroup.MarginLayoutParams params =…
nomnom
  • 1,560
  • 5
  • 17
  • 31
4
votes
1 answer

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
0 answers

Removing a view from OnTouchListener from a dynamically created layout

I have a dynamically created Overlay Window that has an OnTouchListener on a certain layout in the Window. When I detect a a touch with the OnTouchListener, I wish to remove this Overlay Window. This overlay is dynamically created and not part of an…
user1118764
  • 9,255
  • 18
  • 61
  • 113
4
votes
1 answer

AS can't find BottomSheetBehavior_Params, _behavior_peekHeight and _behavior_hideable

I just update my app to Support Library version 24.0.0 and I'm getting some error about BottomSheet Params. The code: /** * Default constructor for inflating BottomSheetBehaviors from layout. * * @param context The {@link Context}. * @param…
4
votes
5 answers

How to change the margin of an "included" layout programatically

I have a LinearLayout inside which I am including a different layout. Something like this
3
votes
0 answers

Android window manager - view above all activities

I'm trying to open a view with WindowManager, a view that will be above all the activities of my app, but not above other apps. This is what i have so far: WindowManager.LayoutParams layOutParams = new WindowManager.LayoutParams( …
liranahum
  • 143
  • 3
  • 13
3
votes
3 answers

RecyclerView items wrap_content width

My Recyclerview is a list of messages. Each item is a linearlayout with a wrap_content width. The problem is that when a new item is inserted, the item would take the previous item's width if it's bigger (Which makes it look like it has a big…
Roudi
  • 1,249
  • 2
  • 12
  • 26
3
votes
0 answers

Setting margin programmatically not working on some devices

In my app I'm creating a RelativeLayout programmatically and setting topMargin. On Nexus 5X, margin is set, however, on LG G4, there is no margin. public static PictureView createPictureView(final Context context) { PictureView newPicture = new…
3
votes
2 answers

FLAG_KEEP_SCREEN_ON working in reverse

This is an odd one. I was previously using: android:keepScreenOn="true" in my layout file to keep the screen on in an activity and this worked fine. However I wanted to improve the so that the screen is only kept on when the web app is in a…
Fat Monk
  • 2,077
  • 1
  • 26
  • 59
2
votes
0 answers

How do I copy and modify LayoutParams to set them on a programmatically created widget?

My goal is to programmatically create and add TextView widgets to a ConstraintLayout, positioned at different angles around a circle relative to another widget, ie using the circular layout constraint. In my activity.xml I add a TextView txtCentred…
2
votes
2 answers

Anyway to keep the height of a layout as wrap content, but not let it exceed a certain height

I have a ScrollView that contains a TextView which is fetched dynamically from a data base. If the text is small in length, I want my ScrollView layout_height to wrap content, however if the text length is big, I want the ScrollView layout_height to…
2
votes
1 answer

Permission denied for window type 2038

I'm fixing an android app not developed by me, a few days ago the client asked me to set the targetSdkVersion to 26 (before it was 14), after I did I noticed that the app crashes in some cases, for example crashes when a ProgressDialog is shown.…
2
votes
1 answer

Cannot programmatically Create multiple EditText with Parameters

Hopefully I'm not missing something stupid. I'm able to create a single EditText and add it to a LinearLayout; however, when I try to do so to an array of EditTexts, I get an NPE on whatever line is first in the for loop. Here is the working…
Kenyx
  • 129
  • 1
  • 1
  • 7
2
votes
1 answer

Flipping RelativeLayout Content when Dragged to Another Side

I have a RelativeLayout which contains 2 ImageView (Character Image and Close Image), and 1 LinearLayout (which contain 1 TextView). Here is my full layout.
2
votes
1 answer

WindowManager - drawing on top of the navigation bar (buttons) Android

Good afternoon. I have a service in which the object is created and WindowManager View - is assigned parameter background (mView.setBackgroundColor(color). The fact is that now I have View drawn only over the main desktop screen and status bar, and…
1
2
3
8 9