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

GridLayout adding customView as a child issue, Android

i have made a simple timetable with GridLayout and it looks like this Now the idea is to insert required subject into specific row and column. In order to achieve that i have created a class that extends CardView in which i need to insert…
vibetribe93
  • 257
  • 8
  • 23
0
votes
1 answer

Android RecyclerView: getting width/height of View with "match_parent"

I have a layout with some Views that I need to change size depending on some parameters, that depend on width of the View. The width is set to "match_parent". So when I try to get the width it returns 0. Here is what I have tried so…
Sermilion
  • 1,920
  • 3
  • 35
  • 54
0
votes
1 answer

How to restore programmatically changed LayoutParams after configuration changes

Say the textsize of a textview defined in the layout file is 12sp, I dynamically changed it to 24sp .but When I rotate the screen, the textsize will change back to 12sp. Is there anyway to retain the LayoutParams that is set at run time when…
user3591494
  • 159
  • 3
  • 8
0
votes
1 answer

Flag WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS does not work with type WindowManager.LayoutParams.TYPE_SYSTEM_ERROR

I'm trying to display a view on the lockscreen and also want to be able to display it partially (eg. half of the view is off-screen when it's 'inactive'). With the type WindowManager.LayoutParams.TYPE_SYSTEM_ERROR as described here and here (and…
Denny
  • 1,766
  • 3
  • 17
  • 37
0
votes
2 answers

FrameLayout with two children( Some View and a ProgressBar, with only one visible at any moment). How to set LayoutParams properly

If I want to show a View with content which takes time to fetch, I'd usually include it in a FrameLayout with a ProgressBar alongside. Show the progressBar while fetching and show the view once the content become available. Example with a…
0
votes
1 answer

How to set LinearLayout LayoutParams to show all height

Based in this question How to set RelativeLayout layout params in code not in xml I've made this code: LinearLayout oLl = new LinearLayout(getContext()); TextView oNum = new TextView(getContext()); oNum.setText(String.valueOf(nPos + 1)…
0
votes
1 answer

Xamarin Android UI Update too slow

I'm developing an Android App with Xamarin.Android and try to update a View about 50 times per second. I used the RelativeLayout.LayoutParams to change the Margin of the View, so that it is moving around depending on the accelerometer values.…
M.D.
  • 273
  • 1
  • 5
  • 18
0
votes
2 answers

Creating button-textview-button dynamically

I'm relatively new to android and I'm trying to create a linear layout with 2 buttons and text view. The buttons will allow me to increase and decrease the value of the text view in the middle of them. Basically I want to achieve something like…
JBJ
  • 288
  • 2
  • 13
0
votes
1 answer

Some RelativeLayout.LayoutParams doesn't work

Background: I'm making an application that can creates timed based alarms, location based or both and in the activity that creates the alarm I have checkbox for each- timepicker and map and you uncheck it if you don't want one of these features in…
Rom Ez
  • 7
  • 1
  • 2
0
votes
0 answers

Validate LayoutParams type in code

Suppose I have the xml: And what I am writing in code: LinearLayout inner = (LinearLayout) findViewById(R.id.inner); RelativeLayout.LayoutParams params =…
Vladimir Ivanov
  • 42,730
  • 18
  • 77
  • 103
0
votes
1 answer

TextureView Align Parent Right Programmatically

I have a customView extending from TextureView. I want this customView to always align_parent_right. My method inside customView has the following code: RelativeLayout.LayoutParams layoutParams = new…
1pratham
  • 113
  • 1
  • 2
  • 9
0
votes
1 answer

Change gravity of list item in Android results in a exception

I have a listview with CursorAdapter (not simplecursordadpter) and I am trying to change the gravity of my list item. The problems seems to be at line: LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) row.getLayoutParams(); Here is…
Luiz Alves
  • 2,575
  • 4
  • 34
  • 75
0
votes
3 answers

Programatically changing Textview height and width

I have a textview that I want to change the width to match_parent and height to remain at wrap_content. It is nested within a horizontal linearlayout. It is the 2nd in 3 textviews each of which has a weight of 1. When this particular fragment is run…
th3ramr0d
  • 484
  • 1
  • 7
  • 23
0
votes
2 answers

Android set margine to root relative layout dynamically

Hi I am developing android application. I am creating view programatically.In my layout I have relative layout as root element. I tried to set margin to my root relative layout. But I am not able to do that. I tried this in following way: public…
nilkash
  • 7,408
  • 32
  • 99
  • 176