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
0
votes
1 answer

Why I cannot set LinearLayout's width programatically?

This piece of code is killing me. I am trying to set the width and height of a LinearLayout (containing children) programatically and the app is breaking. This is the code: LinearLayout ll = (LinearLayout)…
sandalone
  • 41,141
  • 63
  • 222
  • 338
0
votes
2 answers

Android layout parameters fill_parent doesn't have any affect

I have a problem that when I set a layout xml file on an activity with width & height = fill_parent and set a background color as, say, grey, i do not get any background color when I start the activity. I tried creating a custom layout which extends…
Boris Mocialov
  • 3,439
  • 2
  • 28
  • 55
0
votes
1 answer

Modifying button height dynamically in upward direction

I'm trying to create graph-like structure using buttons. I want to modify the height of these buttons dynamically based on the value of seek bar. I'm able to implement this as shown in this screen shot 1. But the problem is buttons grows in height…
GAMA
  • 5,958
  • 14
  • 79
  • 126
0
votes
1 answer

Android LayoutParams do nothing

I have a problem with Android LayoutParams in a TextView. I want to display a Text in a Box of the size 200 dip x 200 dip. But nothing is showing. THis is the Code: tr = new TableRow(this); TextView phone = new…
Bene
  • 636
  • 1
  • 8
  • 24
0
votes
2 answers

How to lay image over another image where the middle of the image should align with the bottom of the image underneath

I have a banner that I am displaying on an Android Layout. On this banner, I have two avatars that I would like to display next to each other, and most importantly, I would like to have them displayed where the midway point of these two avatars on…
Bijan
  • 6,675
  • 6
  • 33
  • 29
0
votes
1 answer

Android - Adding HeaderView to ListView throws ClassCastException

Anyone know how to properly add a HeaderView to a ListView in android? This is what I have: LayoutInflater inflater = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View inflatedView =…
JoshA
  • 133
  • 1
  • 11
0
votes
1 answer

android- Placing two programatically created imageView next to each other in a RelativeLayout

I have created two imageViews promatically as shown below: public void createImageViews(Integer count){ ImageView[] imageViewArray = new ImageView[count]; for (int i = 0; i < count; i++ ) { imageViewArray[i] = new…
Vivekanand
  • 755
  • 1
  • 8
  • 29
0
votes
1 answer

How to make the ActionBar LayoutParams workable for the android 2.x devices

I have successfully created an application which is workable on the >3.0 devices. However, I need to make the application also function-able on the 2.x devices. I would like ask if it is possible to make the ActionBar.LayoutParams also functionable…
Eric
  • 357
  • 1
  • 4
  • 14
0
votes
2 answers

android - how does LayoutParams work?

I am a bit confused about this. I have an app where user draws rectangular text objects. I added some textviews in a relative layout in my xml (lets say that I have a maximum of 3 text objects). The objects can be moved and resized. I added this…
george
  • 1,386
  • 5
  • 22
  • 38
0
votes
2 answers

Using LinearLayout.LayoutParams programmatically

I'm having some trouble with Android's LayoutParams. Basically I am trying to create an application that is completely dynamic, with all layouts generated programmatically and practically nothing beyond my splash screen committed to XML. I am having…
0
votes
1 answer

why MapView.LayoutParams MODE_VIEW does not work if you add x and y coordinates?

when i added x and y coordinates to MapView.LayoutParams constructor. its MODE_VIEW behaviour disappears. I want this behaviour along with x and y coordinates. I am not getting the problem why this is happening. public void addMarkerToMAp(GeoPoint…
yogesh
  • 11
  • 1
0
votes
1 answer

Set LayoutParams Opacity

I have some code (android source), and Im trying to set Opacity of a LayoutParam First, I've got this mLayoutParams = new WindowManager.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, height, …
user809486
  • 888
  • 1
  • 7
  • 15
-1
votes
1 answer

Error - Attempt to invoke virtual method 'int android.graphics.Bitmap.getHeight()' on a null object reference

I'm trying to change the height and the width from fixed to match parent or wrap content when images are loaded into the recycler view https://stackoverflow.com/a/67860281/15537898 here is the answer I'm trying to implement but after it gives me…
user16125085
-1
votes
1 answer

Using layoutparams outside oncreate method doesn't work

I am trying to change my LinearLayout height to 50% of the parent layout when i click a button. I trired it with LinearLayout.LayoutParams but it doesn't change the height of my layout if i call it when buttonClicked from a method outside onCreate .…
-1
votes
3 answers

Add Textview to another activity

I want to create a new textview for my MainActivity from my Main2Activity. I've tried this. What am i doing wrong? Main Activity (this goes with activity_main and at the end makes an intent to change to Main2Activity) package…
1 2 3
30
31