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

Display textView on ImageView programatically in RelativeLayout in HorizontalScrollView

I want to display images and text on each image in a horizontalScrollView. for this I am using RelativeLayout inside horizontalScrollView and adding ImageView and TextView dynamically. It appears as below. the image is displayed only of the text…
user2686960
  • 25
  • 10
0
votes
1 answer

Changing View properties crashes activity

Tried to make a combination of textview elements to show/hide spoilers in text. Problem is that application crashes after start if I add code to initially hide view with text. Tried both setHeight and LayoutProperties, both cause application to…
0
votes
2 answers

how to set a customview to center of an activity in android?

I have made a customView for a .gif image support in android. I got success in that, but currently that view is aligned to the top left corner of my activity. I want it to be aligned to the center of my activity. Please tell me how can I do this. My…
0
votes
1 answer

set size of layout programmatically in android

I want to create a layout depend on size of device screen. This is my MainActivity public class LoginActivity extends Activity { int width_device; int height_device; LinearLayout layout_login_content; LinearLayout.LayoutParams…
Ngo Kim Huynh
  • 69
  • 3
  • 16
0
votes
2 answers

Why does Android NFC not work with my Activity?

Once I modified an Android app and added NFC capabilities. But it just didn't work. The "Tap to Beam" just would not appear. Long story short. The app had: getWindow().setFlags(LayoutParams.FLAG_SECURE, LayoutParams.FLAG_SECURE);
Harald Hoyer
  • 1,303
  • 1
  • 8
  • 8
0
votes
1 answer

Android: change width in Table Layout using LayoutParams so the content can be fit

So I am creating a table that contains the texts that are very long with 4-5 columns, and what I need is the table that is able to WRAP content in each column (in width and height). I want all of my content can be seen. If the texts are long, the…
0
votes
1 answer

put a button on the Relative Layout and move it independently

I have a layout that always rotate to the north. I want to put a pointer on it, but pointer should not rotate. how can I do that? this is my code of Layout: rll = (RelativeLayout) findViewById(co.iman.R.id.relativeLayout1); rlllp = new…
0
votes
1 answer

Android - setting the "android:layout_column="1"" programatically?

How can I set the android:layout_column="1" programatically? I've seen some other answers but all of them are something that doesn't really work with my code. All of them say to do something like this: layout.setLayoutParams(new…
Groot
  • 483
  • 1
  • 9
  • 20
0
votes
2 answers

Only last added button is shown

I am trying to add 9 buttons programmatically to a FrameLayout but only the last one is shown. The code below is for the first button and I am doing like that for all the other buttons, but with different coordinates. I want to add each button with…
0
votes
1 answer

Inflate a custom view from XML, then set her height and witdh programmatically

I'm loosing myself in an custom size View problem since a couple of days. After some long research, I finally decide to ask your help... please ! T_T In my app, I created a custom View with the XML calendrieradmin_day.xml :
0
votes
2 answers

Set height of ListView onClick

My ListView is currently stuck in a little small view-box on the bottom of my screen. When it's clicked, I want it to expand to some height. I've read guides on here on how to do that, but nothing seems to work. Here's my code here. …
Miles Peele
  • 325
  • 5
  • 15
0
votes
1 answer

ImageView Disappears when trying to Set the Width and Height programmatically

Here is my code onCreate() { img = (ImageView)findViewById(R.id.img); Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); int w = size.x; int h = w * (9/16); …
uLYsseus
  • 995
  • 6
  • 16
  • 37
0
votes
1 answer

Android RelativeLayout + TextView dynamically

I created a layout dynamically, inside TextView I want to display 2. It works, but how can I position the TextView, one right and one left? Thanks ScrollView sv = new ScrollView(this); sv.setLayoutParams(new…
user3608814
  • 561
  • 1
  • 8
  • 23
0
votes
1 answer

Setting bottom margin in RelativeLayout.LayoutParams via Java code not working

I am trying to create a stack of cards dynamically by using a RelativeLayout and setting the ALIGN_PARENT_BOTTOM rule and the bottomMargin. But the cards keep getting drawn over each other disregarding the margin. But they draw properly when I use…
0
votes
2 answers

Resize ImageView even if ScaleType

I have a problem, I'm trying to resize a ImageView and its parent container but the problem is that the ImageView has ScaleType:"matrix", and I cant`t resize the image or its container this is my code: public void resize() { LayoutParams contet…
Omar
  • 51
  • 9