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 can I change the layout order with one button?

I've create one layout with 3 RelativeLayout includes. 2 of these are invisible and I want to make them visible and to the top when I press one button. Is it possible? How can I make android: layout_below="@id/pag6a_1" programmatically? it…
0
votes
1 answer

Defining Layout Sizes

I want to make such a layout that basically will have 2 columns. There'll be TextView and Editext on the same row. But what I want is to set some Fixed size or weight to each column. I know I can set weights to TextView and EditText but I don't want…
Jilberta
  • 2,836
  • 5
  • 30
  • 44
0
votes
1 answer

Aligning ImageView to LinearLayout programmatically

I need to programmatically align an ImageView to the bottom of a LinearLayout. I, of course, already tried to add the ImageView as a child of the LinearLayout, but the image get shrinked (cause the LinearLayout is smaller than the image), and I need…
0
votes
2 answers
0
votes
1 answer

How to animate the height of a View?

i have a method i created that is called throughout my project, i made it because i have a Crouton (toast) that tells a user to activate there account, or it will also alert them when there is no valid internet connection... And i dont want it to…
0
votes
2 answers

How to position a inflated layout at the center of parent layout

I am inflating a layout(imageviewlayout) in Main layout.I am getting the child view at t he bottom of parent view.How can I align the child view at the center of Mainlayout.I have read that it can be done using Layoutparams .can you please tell how…
ss45
  • 47
  • 1
  • 9
0
votes
1 answer

Strange beavior with LayoutParams

I am currently playing around a bit with code generated Layouts. There I recogniced a problem in this part of code: dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); int dp_x = (dm.widthPixels - 32) / 10; for(int x =…
Jochen Birkle
  • 335
  • 4
  • 14
0
votes
1 answer

Add views in to a relative layout programmatically for Android

I am trying to create views to add in to a Relative Layout and have views inside a Relative Layout to then be displayed on the main layout. This will then look like container boxes with elements inside and I want to be able to add a layout with the…
0
votes
2 answers

Programatically place TextViews underneath eachother in a RelativeLayout

Problem I've been trying to place a couple of TextViews underneath eachother, but I can't seem to get it working. They always overlap eachother in stead of getting placed beneath eachother. What have I tried I've tried messing with gravity (which…
Bono
  • 4,757
  • 6
  • 48
  • 77
0
votes
0 answers

gridview inside listview layoutparams android

use: public View getView(int position, View convertView, ViewGroup parent) { final int type = getItemViewType(position); if(position == 1){ GridView gridView = new GridView(context); gridView.setNumColumns(3); AbsListView.LayoutParams…
slip.08
  • 1
  • 2
0
votes
1 answer

Android: application has stopped unexpectedly please try again Why?

I want draw screen programmatically and not through layout-file. I write: // create LayoutParams LayoutParams linLayoutParam = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); // install linLayout …
Paushchyk Julia
  • 516
  • 3
  • 8
  • 24
0
votes
1 answer

Getting wrong width, height info

I have set frame of a ViewB using setLayoutParams(params) from mainActivity class. When I am checking ViewB's frame in ViewB class, I am getting width, height improper. (getting width= -2, height=-1) do any know the reason? Thanks
macpandit
  • 835
  • 1
  • 7
  • 11
0
votes
0 answers

setting center_horizintal property as false

I have set align_center_horizontal as true in my layout xml . but sometimes I do want to set as false . I found that there is no FALSE variable as such defined in RelativeLayout so that I can make it false at runtime If it is possible to achieve how…
Rohit Walavalkar
  • 790
  • 9
  • 28
0
votes
2 answers

How do I get the `layout_weight` of a TextView?

I have a TableLayout and a row with a couple TextViews. I want to find the layout_weight of the TextView but I cant figure out how. I've tried the following: TableRow.LayoutParams lp = tv1.getLayoutParams(); and: ViewGroup.LayoutParams lp =…
linitbuff
  • 359
  • 3
  • 8
0
votes
2 answers

ImageView doesn't rescale Image to selected size

I'm using a ImageView with a fixed size for adding an icon to a menu. In my application, I use it a lot of times, but on this ImageView the Layout Params seem to not work. Unlike the others ImageViews, in this case, I'm using a template directly,…
jramirez
  • 486
  • 9
  • 24