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

Not able to set gravity to imageview programmatically

I have following view I want to set gravity programmatically to ImageView but unfortunately I am not able to do it, I have read lot of SO questions and answers but still nothing working
eLemEnt
  • 1,741
  • 14
  • 21
-1
votes
4 answers

Align dynamically created textview and edit text in android

I have a relative layout and 'n' number of textviews and edittext . I want the alignment as TextView EditText Button TextView EditText Button TextView EditText Button TextView EditText Button …
Anusha
  • 939
  • 3
  • 13
  • 31
-1
votes
1 answer

What is the right way to create layout for different screen sizes?

First situation Let's say I have a screen with several buttons placed in vertical order. I distributed available space between them using weights. So, on a large screen buttons get bigger. That's what I want. But how I make the text look bigger…
T.Vert
  • 279
  • 2
  • 13
-1
votes
3 answers

Change width of a ListView item(row)?

I have a ListView that every row shows different percentage. and I wanna change one of inner layouts width (inside inflated counterView) for this purpose . for example: if first value item in listview is 10% then width set to 10px too if second…
Amin SZ
  • 359
  • 3
  • 11
-1
votes
1 answer

a LayoutParams constructor overload with size in dip. Why not?

In Android SDK there isn't an overload of a constructor of ViewGroup (and subclasses) with possibilities to specify the width and height in DP (or DIP) instead of in pixel. Why? Actually we have: ViewGroup.LayoutParams(int width, int height) Could…
aorlando
  • 668
  • 5
  • 21
-1
votes
1 answer

Why this code can not run on HTC but run on other android phones?

I mean I write this code : getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); it is run on sony ,samsung... but it is error on htc phone(wildfire s).Why? maybe this is reason? java.lang.IllegalArgumentException: View not attached…
CompEng
  • 7,161
  • 16
  • 68
  • 122
-3
votes
3 answers

RelativeLayout.LayoutParams causing app crash in android

I had a recycler view for which I have a linear layout as parent and a relative layout as child. I'm changing the layout params to these dynamically. My code is working pretty well for linear layout but when it comes to relative layout it is…
Bharat
  • 1,044
  • 15
  • 34
-4
votes
2 answers

Android : Unable to change width of dynamic button

I am trying to make dynamic buttons of fixed dimensions. I am able to alter the height but unable to change the width. The width of the button seems to MATCH_PARENT (it takes up whole screen width. If there are two buttons, each button width is half…
-4
votes
1 answer

Conversion between px and dp unit

I want to set layout_marginTop to 800px using setLayoutParams(). But I want know what would be this value in dp unit? Thanks in advance.
1 2 3
30
31