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

How to programmatically set Layout to Top and Start of screen?

You can set a LinearLayout to the top left of a screen by doing this: android:layout_alignParentTop="true" android:layout_alignParentLeft="true" I was wondering how would I do this programmatically? I have the following piece of code: …
Foobar
  • 7,458
  • 16
  • 81
  • 161
0
votes
0 answers

if I set setLayoutParams() for a layout, what happens?

If relativeLayout is a root layout in a xml, I set a LinearLayoutParams for it, what happens? It will be a linearLayout or it will be subviewGroup of linearLayout?
zhangkaiyue
  • 125
  • 12
0
votes
1 answer

Not able to set width and height of FloatingActionButton dynamically by setLayoutParams

I don't want to use normal or mini size of FAB. So, i'm trying to set width and height of a FAB by using LayoutParams but setLayoutParams is not working. I tried the same with ImageButton since FAB extends ImageButton and it worked for ImageButton.…
anubh
  • 649
  • 7
  • 12
0
votes
2 answers

Issue Filling Parent View When Inflating Linear Layout

The LinearLayoutOutlined class I'm using is from this answer with only a few small edits for color. This is what my current activity looks like. There is a horizontal scroll view in the center that I want to fill with items by putting them in the…
flakes
  • 21,558
  • 8
  • 41
  • 88
0
votes
3 answers

Create fragment and set parameter programmatically

I have the following problem in code I create fragment and that is OK. My problem is when I try to set him and parameter. Here is my code. LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( 0,…
OneByte
  • 101
  • 1
  • 5
0
votes
0 answers

How is margins calculated for textView when it is set upside down?

I do this: question1.setRotation(180); RelativeLayout.LayoutParams for_question1_x = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT); …
ERJAN
  • 23,696
  • 23
  • 72
  • 146
0
votes
2 answers

Error while compiling android example for GridView

Im trying to write a simple adapter for GridView exactly from google example for GridView ; here's my getView function . public View getView(int position, View convertView, ViewGroup parent) { ImageView imageView; if (convertView ==…
Erfan Bagheri
  • 638
  • 1
  • 8
  • 16
0
votes
2 answers

Handling Click Event of ImageView which is dynamically added

Code : maxIndex = alItemListDetails.size(); linItemTags = (LinearLayout) findViewById(R.id.linItemTags); final ImageView image = new ImageView(this); for (int i = 0; i < maxIndex; i++) { image.setLayoutParams(new…
Jaimin Modi
  • 124
  • 1
  • 15
0
votes
0 answers

how to create Sliding Up Panel without using any library in android

In single view I want to display map and list of places in recyclerview so I divided my layout by using weight. Now it will show map half screen and list half screen based on place recyclerview scrolling I want to display location of the place in…
Ganesh P
  • 196
  • 1
  • 14
0
votes
1 answer

TextView is not placed according to layout params first time, but afterwards works fine

I have a textview that must be put in center of screen in relative layout. TextView displays random question, when i select answers, new text is put in the textview. The very first time activity runs, it stays somewhat off the center, but as i…
ERJAN
  • 23,696
  • 23
  • 72
  • 146
0
votes
1 answer

Change ImageView size on WindowManager programmatically

I have an ImageView service that added to the WindowManger here is the code android.view.WindowManager.LayoutParams layoutparams = new android.view.WindowManager.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,…
0
votes
1 answer

Android Listview item clicks and back button not working with floating window on top

I have successfully implemented a floating window to be displayed from a Service on top of all activities using Window Manager services. Also, I am handling the touch events to be able to drag it. As desired, the touch and click events on the…
0
votes
1 answer

ValueAnimator/Expand/Collapse view not giving correct height

I have a search bar that expands when icon is clicked in toolbar. Now, everything is cool when it is expanded, everything works fine, the thing that is not good is that the height isnt good when the search bar is collapsed. The toolbar upon…
Miljan Vulovic
  • 1,586
  • 3
  • 20
  • 48
0
votes
1 answer

setLayoutParams of FrameLayout in tableRow element / view not showing

If I remove the line indicated, the "elements" are displayed, although they are to big and go partly out of the screen, if I try to set the width and height (LayoutParams) of an element inside the tablerow, the tablelayout is displayed…
0
votes
1 answer

Modify columns width from code android

I would like to know if there is a way to modify the width of two columns in a table layout (with three columns in total). The problem is that every column has the same width and a lot of space is wasted because the first two only contain an id and…