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

123 questions
2
votes
0 answers

Android programmatically change dialog xml height

In my fragment, if a certain text field is not filled out a error message is displayed to the user in the form of a Dialog, which is displaying as itended. However, I require the height of the Dialog box to change programatically depending on the…
reyyez
  • 365
  • 2
  • 3
  • 16
2
votes
1 answer

Horizontal RecyclerView height wrap content not working

I have a custom horizontal RecyclerView which is inside a vertical listview. The problem is, I can't use wrap_content in recyclerView. Right now I am setting a height of 455dp. I tried a custom LinearLayoutManager too, it fixes the wrap_content…
Amit Tiwari
  • 3,684
  • 6
  • 33
  • 75
2
votes
1 answer

Change ImageView position dynamically not working in Android

I have an Activity that have an ImageView inside a RelativeLayout and I want to be able to move the ImageView inside the RelativeLayout and when I remove my finger I want the ImageView to get back to its original position. I have tried the…
2
votes
2 answers

Using FLAG_NOT_TOUCHABLE, gives Not Responding error

Is there any way to remove that error? I am using FLAG_NOT_TOUCHABLE in my activity, but when I touch the screen it appear not responding error... WindowManager.LayoutParams params = getWindow().getAttributes(); params.flags |=…
1
vote
1 answer

Top-level Layout in Android XML is ALWAYS FrameLayout?

I was trying to set height of ConstraintLayout programmatically and I intended to use ConstraintLayout.LayoutParams. ConstraintLayout is a top-level layout in this XML. but I had weird experience when I set height from old to new with…
1
vote
1 answer

How to reset android:stateListAnimator from null to the default style of the button in Android`

I implemented a costumized "enabled" button in Android. I set android:stateListAnimator="@null" when my button is disabled and want to reset it to the default Widget.AppCompat.Button style, when it is enabled. But how can I reset it? What do I have…
1
vote
1 answer

How to show Alert on top of all Activities in android?

I am doing an AsyncTask to call an API call in my application. And showing the API response as an Alert. I have written that API calls on home screen activity and showed that alert on top of the home screen. But if I moved from that activity to…
1
vote
2 answers

How to define textAppearence value in android layout

In my layout, I am using falling for predefined values for android:textAppearence. But, there are, as I found, at least 2 ways to define them, which yields a very different result (like, different font size and alpha and weight…
BaRud
  • 3,055
  • 7
  • 41
  • 89
1
vote
1 answer

Relative Layout adding views programmatically one below other not aligning correctly

I am trying to add Text views programmatically to Relative layout parent one below other. However, the first view is not aligning correctly while the rest of the view got aligned correctly. See attached image. My code: private void…
1
vote
0 answers

android constraintLayout ellipsize text starting different offset

I have this android layout (root is a constraint layout) TextAppearance.My end start 1 and
Elad Benda
  • 35,076
  • 87
  • 265
  • 471
1
vote
1 answer

LayoutParams overwrite themselves

I'm developing a little game and I need to give different ImageViews different LayoutParams. Therefore I created an array ConstraintLayoutParams. After changing the properties of the layoutparams seperately, all the layoutparams have the same…
1
vote
2 answers

How Android UI should vary? Density (DPI) wise or as per screen size? Best practice to follow?

I am developing the app for mobile and tablet devices. In following screenshot I have applied button size as android:layout_width="200dp" android:layout_height="80dp". When I run my application in a tablet(mdpi) and in other two mobile devices…
1
vote
0 answers

View move to top after remove Relativelayout Rule in android

I've added RelativeLayout into RelativeLayout by using below code. var _root: ViewGroup? = null private var _xDelta: Float = 0F private var _yDelta: Float = 0F lateinit var layoutParams: RelativeLayout.LayoutParams override fun…
Mahesh
  • 355
  • 1
  • 5
  • 17
1
vote
1 answer

calculate listview height based on children

I have list view inside scroll view and do calculation height base of children. Here is code I use : public static void SetListViewHeightBasedOnChildren (ListView listView) { IListAdapter listAdapter = listView.Adapter; if…
Nininea
  • 2,671
  • 6
  • 31
  • 57
1
vote
1 answer

Android Define Match_Parent in Dimens XML

How can i define the match_parent flag in a dimens.xml? match_parent I tried the methods here Value equals to match_parent or fill_parent in dimens.xml? but none work. Iam using Android > 27 API.
Nick
  • 2,818
  • 5
  • 42
  • 60
1 2
3
8 9