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

set remaining height to view at runtime

I am writing an application where need to assign rest of screen space to view.
CoDe
  • 11,056
  • 14
  • 90
  • 197
0
votes
0 answers

Limit for ImageView's position

I created an ImageView that I can drag over the screen. But sometimes it goes out of the screen, and I am trying to solve it. How can I define minimum and maximum limits fot the x and y coordinates of the imageview? I tried this, but…
Danilo
  • 11
  • 1
  • 5
0
votes
1 answer

Android 5.0 Lollipop dismiss secure lock keyguard

I have an activity that is correctly shown in front of the keyboard when an alarm goes off. Everything works fine, I set the following…
0
votes
1 answer

Handling ClassCastException when we set LayoutParams programmatically

I am doing like this - OPTION 1: Setting params first time: FrameLayout fLayout = (FrameLayout) getActivity(). findViewById(R.id.headlines_fragment); fLayout.setLayoutParams(new LinearLayout. LayoutParams(310,…
sjain
  • 23,126
  • 28
  • 107
  • 185
0
votes
1 answer

How to set layout params using view's on touch listener?

I want to create drawing layout like this xml layout of screen Layout at the bottom in gray is like a drawer its can be adjusted by dragging up and down. So I want to adjust its hight when user takes it up or down. I have used onTouchListener for…
Narendra
  • 609
  • 1
  • 12
  • 28
0
votes
0 answers

Get rowSpec and columnSpec from Button in GridLayout

I have a gridlayout containing buttons. If I touch one button I want to know which button it was. Therefore I need the span of the rowSpec and columnSpec. ViewGroup.LayoutParams layoutParams = clickedbutton.getLayoutParams(); String rowSpec =…
0
votes
2 answers

Android: Setting a button size programatically

I'm trying to make a 100x100 px button and add it to a gridlayout on the position 3,3 Button btn = new Button(this); btn.setLayoutParams(new ViewGroup.LayoutParams(100,100)); GridLayout grid4x4 = (GridLayout)findViewById(R.id.grid4x4); //I've…
Artemio Ramirez
  • 1,116
  • 1
  • 10
  • 23
0
votes
1 answer

Changing width of individual items in a listview

So I've searched around for an answer or a possible solution to this problem for a couple weeks now and still haven't gotten any farther. I'm working on building an app that rewards users with points after certain things. One of the pages they can…
0
votes
1 answer

Unexpected clipping in dynamic viewgroup construction

I construct a horizontal scrolled strip with images captured before and I want that items of this strip look like BUT CURRENTLY I SEE JUST The construct process is realized in function: FrameLayout getImageContainer(){ //Call custom…
Sergey V.
  • 981
  • 2
  • 12
  • 24
0
votes
1 answer

Set maxHeight for a ViewGroup

A ViewGroup has a property called minHeight which allows you to set the minimum height of the ViewGroup. http://developer.android.com/reference/android/view/View.html#attr_android:minHeight There is no property called maxHeight. So how exactly can…
Etienne Lawlor
  • 6,817
  • 18
  • 77
  • 89
0
votes
3 answers

How to set height of the imageView programatically?

I want to set the height of the image view programatically in gridview. I used below code- imageview.getLayoutParams().height = height; This is working fine in android version 4.3 and higher but not working in android version 4.2 and below. I can't…
Jagveer Singh
  • 584
  • 7
  • 28
0
votes
1 answer

Optimizing ListView without using LayoutParams.MatchParent

I have a ListView. I notice that if I set the LayoutParams like the below, the ListView fetches each cell a lot of times, which makes things slow. [Code is C# as this is via Mono:] var layoutParams = new RelativeLayout.LayoutParams (someWidth,…
William Jockusch
  • 26,513
  • 49
  • 182
  • 323
0
votes
1 answer

Margin / Padding on custom View

i have created a custom view CameraView extends View{ ..... } in OnCreate methode i have define as cameraView = new CameraView(this); LayoutParams layoutParamsCamera = new…
Sumit
  • 1,022
  • 13
  • 19
0
votes
0 answers

Chathead LayoutParams NullPointerException

Hi i'm building app similar to Chathead. My service is checking if other app is in foregnound and if yes service hide chathead(ImageView move out of linearlayout and linarlayout is untouchable). Problem is, that after few hours running app, when…
Lalson
  • 293
  • 1
  • 3
  • 14
0
votes
1 answer

Does Android RelativeLayout LayoutParams can set R.id ?

In my app, I create the gridview and then add the view by RelativeLayout LayoutParams. But how can i call it in another activity? such as gridview looping the 10 article and hide the icon, i create the edit button to control hide/show the icon. but…