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

Set programmatically margin in android?

I have bellow xml . In this xml i need that set MarginTop "@+id/imgFooter" programatically toward "@+id/imgCenter" .But i Can't . My XML :
3
votes
1 answer

Dynamically add view with LayoutParams

I want to add an ImageView on LinearLayout with specific LayoutParams. When I use an ImageView which is defined in dot_layout.xml, the layoutParams works fine (Commented line). However, when I dynamically created and add ImageView with layout…
Nari Kim Shin
  • 2,459
  • 1
  • 25
  • 33
3
votes
3 answers

ListView row set Left Margin programmatically in CustomAdapter

I have a ListView with its Custom Adapter. in adapter's getview i want to set margin left of 15 dip to some rows. based on certain conditions. ----------------------------- | Row 1 (margin 15dip) | ----------------------------- …
Shashank Degloorkar
  • 3,151
  • 4
  • 32
  • 50
3
votes
4 answers

searchview not expanding full width

Basically I want the searachview to expand and collapse when there is a imagebutton behind which should disappear when icon is clicked and view should appear when searchview collapses. I am using search view not in action bar .When i click on the…
jason
  • 3,932
  • 11
  • 52
  • 123
3
votes
2 answers

How to set ActionMode LayoutParams to make custom view match_parent?

I'm trying to set a custom view into an ActionMode, but it doesn't match ActionMode as parent. In comparison with the standard ActionBar, when you are setting a custom view you can specifiy layout params, while is not provided in ActionMode. There´s…
3
votes
1 answer

Disable screen capture functionality

I know that we can suppress screen capture functionality using the code getWindow( ).setFlags( LayoutParams.FLAG_SECURE, LayoutParams.FLAG_SECURE ); But, In my case I have a library, and on a button click I call a method from Library and that…
Sachchidanand
  • 1,291
  • 2
  • 18
  • 35
3
votes
2 answers

Seekbar not setting .getLayoutParams().height

I have a Seekbar that works perfectly except for one part. I want to adjust the height of a textView depending on the Seekbar value. I'm using this code to adjust the height of the textView: SeekBar sb1 =…
3
votes
4 answers

Android - image view inside view pager issues

I have an image view inside view pager to display some images coming from url as shown in the screen shot below, However, the image should be filled( should occupy the complete view pager space). But what is happening in my case is the image is…
3
votes
3 answers

How to set completionThreshold to AutoCompleteTextView with java code?

I have this AutoCompleteTextView: AutoCompleteTextView a = new AutoCompleteTextView(this); I need to set completionThreshold flag value to 1, and i want to learn doing it with java code. I searched on google and stackoverflow and i didn't found…
3
votes
1 answer

Dynamically filling a Table Layout with Table Rows

I have a table layout inside a scroll view , I want to fill them dynamically with 5 N Table Rows. Each Table Row contains an ImageView and an EditText. The app crashed Here is the complete stack: 09-25 10:03:07.496: E/AndroidRuntime(1695): FATAL…
Karim M. El Tel
  • 438
  • 1
  • 7
  • 19
3
votes
1 answer

WindowManager.LayoutParams Animations

I have an ImageView that I'm adding through WindowManager.addView(ImageView, WindowManager.LayoutParams). I want to animate the ImageView when it appears on the screen but it doesn't seem to animate when I call ImageView.startAnimation(Animation)…
Brian
  • 7,955
  • 16
  • 66
  • 107
2
votes
2 answers

Set LayoutParams on parentless LinearLayout

I creating LinearLayout programatically then I want to attach it to GridView via custom written adapter. I want to set width and height to my newly created LinearLayout. When I try to do so I get following exception: 03-18 15:50:54.648:…
Alex Amiryan
  • 1,374
  • 1
  • 18
  • 30
2
votes
1 answer

Android: Using LayoutParams to set width of View object

I have a UI element that I am working with in my Android app that has a custom width. The UI element essentially is a block with two green circles - one circle on the left of the block, and the other circle on the right of the block. I want to be…
David
  • 1,847
  • 4
  • 26
  • 35
2
votes
1 answer

use setLayoutParams() but it doesn't work

I create a custom view-MyImageView-to draw a bitmap in it,i use setLayoutParams() to set my view's width and height,but it doesn't work,i use log to track my view's width and height,i found that both of them are 0,why the width and height are not…
2
votes
0 answers

Controlling problem in android layouts

I tried to show new view on the center of relativelayout. But the new view always places on the top of screen. LayoutInflater inflater = (LayoutInflater)this.getSystemService("layout_inflater"); dest = inflater.inflate(R.layout.searchlayout,…
smiler
  • 315
  • 1
  • 3
  • 8