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

How to create two LinearLayout with equal width programmatically?

I'm trying to create two LinearLayout with equal width programmatically: mGroupLayout.setOrientation(HORIZONTAL); mGroupLayout.setWeightSum(2f); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( 0, …
Yuriy Kolbasinskiy
  • 3,791
  • 3
  • 16
  • 33
1
vote
1 answer

How to change width and height of existing layout params

Please consider ImageView inside RelativeLayout it has some specific layout params for RelativeLayout. I need to change the width and height of my ImageView programatically according to the screen size. How can I save all layout parameters but only…
user4881271
1
vote
0 answers

Automatically Increase layout height and width when view animate to bottom

I have three views(A, B, and C) which are stacked over one another. So when I click on a button the two views (B and C) animate from behind View A and scroll down to the bottom. Now my animation is working fine but the views B and C are extending…
1
vote
2 answers

How do I set LayoutParams for ImageView

I have an ImageView in my app. My question is how I can set params to it? ImageView header = new ImageView(getActivity()); I used this way but I face with classCastException ImageView header = new…
Erfan Eghterafi
  • 4,344
  • 1
  • 33
  • 44
1
vote
1 answer

UnsupportedOperationException: addView(View, LayoutParams) is not supported in AdapterView

I am trying to create a simple Android app and I'm getting this error: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.twista.shopinglist/com.twista.shopinglist.ItemDetail}: java.lang.UnsupportedOperationException:…
Michal Hatak
  • 797
  • 1
  • 9
  • 21
0
votes
0 answers

What's the best approach in android development to scale a view to a percentage of the parent's dimensions?

In my current project there are numerous instances where I want to scale a View as 1/8th of its parent container because I have to make use of all the space at my disposal, since I have so many features to implement on a small android device's…
0
votes
1 answer

Resolution specific dimensions are not working as expected in Android

I had to adjust the layout dimensions for HDPI devices. So, I added the dimensions in values-hdpi folder. dimen decleration in values-hdpi folder 8dp dimenn…
0
votes
1 answer

Converting Layout params animation from Kotlin to Java in Android Studio

I have an onScrollListener animation in my Kotlin project and I will like to use that code in my java as well, I have tired to convert the Kotlin code to Java but i am see some error and my app crashes when it detects the onScrollListener the…
0
votes
0 answers

Outer ViewGroup attributes to be applied by all children of nested ViewGroup

I need to create custom viewgroup that contains children which are proceeded with the attributes of the outer viewgroup for my custom. For example,
0
votes
0 answers

Android. Custom font not working when setting from style

I'm trying to set programatically style for my button. Here is my style: