Questions tagged [android-layoutparams]

The base LayoutParams class just describes how big the view wants to be for both width and height. For each dimension, it can specify one of:

  • FILL_PARENT (renamed MATCH_PARENT in API Level 8 and higher), which means that the view wants to be as big as its parent (minus padding)
  • WRAP_CONTENT, which means that the view wants to be just big enough to enclose its content (plus padding) an exact number

There are subclasses of LayoutParams for different subclasses of ViewGroup. For example, AbsoluteLayout has its own subclass of LayoutParams which adds an X and Y value.

Useful links

113 questions
0
votes
1 answer

How to set height of a layout after the layout was already created

I spent several hours trying to do this, but finally I gave up. I have a LinearLayout. Inside of it I have another LinearLayout that is initially hidden. When some condition occurs, I need that hidden layout to be shown and the containing layout to…
jstuardo
  • 2,687
  • 10
  • 44
  • 101
0
votes
2 answers

WindowManager.addView ontop(overlay) of soft key OR nav bar

I saw an app that overlays whole screen including nav bar (or soft-key that has back, home, etc.) today. it's CF.Lumen(requires android 4.4+) by chainfire. I just remembered this is NOT POSSIBLE on general approach and many SO answers told me. So I…
-1
votes
1 answer

Android switch item position programmatically in a RelativeLayout

I have a RelativeLayout displaying an app name with its icon below. I want to be able from the java side to switch icon and text positions, so the app name is displayed below the icon without having to inflate a new view. How can this be…
Mo Dev
  • 395
  • 3
  • 12
-1
votes
1 answer

Setting LayoutParams but its not working android

Trying to create a linear layout programmatically and setting its width and height by layout params. But it seems layout params isn't working. this is the code: // CREATING A NEW LINEAR LAYOUT PROGRAMMATICALLY LinearLayout linearLayout = new…
Arpit Chhabra
  • 173
  • 1
  • 11
-1
votes
1 answer

"Attempt to invoke virtual method on a null object reference" when trying to getLayoutParams of a CardView in a DialogFragment?

I'm trying to set the size of a CardView inside of a DialogFragment, but I get this error: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.ViewGroup$LayoutParams android.support.v7.widget.CardView.getLayoutParams()'…
-2
votes
1 answer

Android add editText proggramatically onClick

so I know the onClick part is quite useless, but just in case it does change anything, ive put it there. so ive got the onClick, and I would like it to add the editText to the current activity, which is called activity_calculation. I currently have…
-4
votes
1 answer

How to show Toast when I click on the LayoutParams TextView

This is single TextView which is containing values form database. So I want when I click on the TextView, it should show Toast the same text in the position I clicked. The image showing the text view
MaLik Farooq
  • 25
  • 1
  • 6
-4
votes
2 answers

Custom Dialog not showing View

I made a simple project if button click custom dialog appears but when I think something is missing in it? Toast message appears when i click on button but dialog not showing and also no error occurs and app not crash. source code private void…
1 2 3 4 5 6 7
8