Questions tagged [layoutparams]

The LayoutParams is a helper class that stores various layout information related to the Android view for which it is used.

The LayoutParams class is generally implemented as a nested class(in the ViewGroup that will use it) and it is present in all of the platform's default subclasses of ViewGroup. The class stores information like the widget size but can also store other details like the gravity of the view or the coordinates on the screen. Each of this value will be used by the parent to determine how to show that child View on the screen.

The LayoutParams is an important class and the user should take care and always use the appropriate LayoutParams for each View. The general rule of setting a LayoutParams for a View is to use the type of LayoutParams declared by its parent.

459 questions
15
votes
2 answers

Android: change LayoutParams of View added by WindowManager

I have overlay View managed by WindowManager, just like in this question. Briefly, it looks like this: WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE); my_view_layout_params = new WindowManager.LayoutParams( …
Dmitry Frank
  • 10,417
  • 10
  • 64
  • 114
15
votes
2 answers
12
votes
2 answers

TYPE_SYSTEM_OVERLAY in ICS

In Honeycomb I was able to create a system overlay with TYPE_SYSTEM_OVERLAY and receive touches with FLAG_WATCH_OUTSIDE_TOUCH. Now ICS has changed something. I can still create the system overlay, but i can't get touches. Now, i am able to create…
12
votes
1 answer

How to get width and height of displayed image in android?

This question may seem trivial and been asked many times, but I couldn't find an answer that will work for me. I have an ImageView and GLSurfaceView that is drawn on top of ImageView when I push a button. For my ImageView I pass a Bitmap and scale…
Fedor Tsyganov
  • 992
  • 13
  • 30
11
votes
4 answers

Animate LayoutParams changes in ConstraintLayout

I am creating app in which there is screen with searchBar by this lib. My activity layout looks like this:
Qiteq
  • 675
  • 1
  • 6
  • 22
9
votes
2 answers

view.getLayoutParams().width not working with nougat

I have written code to set height and width of view dynamically view.getLayoutParams().width = 120; view.getLayoutParams().height = 120; It works perfectly with below nougat devices, but with nougat it is not working. It is just taking height and…
Ravi
  • 34,851
  • 21
  • 122
  • 183
9
votes
3 answers

Why use "setLayoutParams" after "getLayoutParams"?

For example, if you want to change LayoutParams of some view to WRAP_CONTENT for both width and height programmatically, it will look something like this: final ViewGroup.LayoutParams lp = yourView.getLayoutParams(); lp.height =…
Nik Myers
  • 1,843
  • 19
  • 28
9
votes
3 answers

How to disable screen capture in Android fragment?

Is it possible to disable screen capture from a fragment? I know the below works for an Activity class onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, …
kdas
  • 602
  • 2
  • 7
  • 22
9
votes
5 answers
8
votes
1 answer

Setting Button's margin programmatically

I am new to android and stuck in a very basic problem.I am working on an application in which I need to swipe images on fling.On every image I have to add buttons dynamically.I am adding buttons using AddContentView() to add buttons.Everything is…
user1022105
  • 101
  • 1
  • 2
  • 5
8
votes
1 answer

Why do 9-patch graphics size correctly in the emulator but not on a phone?

I have a RelativeLayout that has a 9-patch background image. The image is a simple speech bubble with a perfectly centered "arrow" at the bottom middle. The RelativeLayout is inflated and placed on a MapView. Using the emulator, the speech bubble…
originalbryan
  • 1,027
  • 1
  • 13
  • 21
8
votes
5 answers

Android WindowManager TYPE_SYSTEM_ALERT Layout on touch

my app displays a button to user at certain times as TYPE_SYSTEM_ALERT and I am trying to let user to move it around. Touch and move action does register with below code but button doesn't move. What am I missing? //create button mbtRec =…
nLL
  • 5,662
  • 11
  • 52
  • 87
7
votes
2 answers

Allow user to control height and width of a view by onTouch

I am trying to implement a user resizable edittext view. It can be resized when user drags the edges of the view. Here is my onTouchListener for edittext. I have only implemented resizing for left edge. My idea is as the user's touch event x equals…
Alex
  • 881
  • 2
  • 10
  • 24
7
votes
3 answers

Null Pointer Exception when setting LayoutParams

I created button in activity programmaticaly, not in xml file. Then I wanted to set it LayoutParams like in this link: How to programmatically set the layout_align_parent_right attribute of a Button in Relative Layout? But when I tried to launch, I…
Askar Zaitov
  • 283
  • 1
  • 6
  • 15
1
2
3
30 31