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

Anyway to keep the height of a layout as wrap content, but not let it exceed a certain height

I have a ScrollView that contains a TextView which is fetched dynamically from a data base. If the text is small in length, I want my ScrollView layout_height to wrap content, however if the text length is big, I want the ScrollView layout_height 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
  • 2,609
  • 2
  • 31
  • 70
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
  • 30,720
  • 75
  • 234
  • 415
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…
Kavita_p
  • 1,373
  • 1
  • 10
  • 22
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…
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,451
  • 4
  • 26
  • 50
1
vote
4 answers

How to specify in XML a percentage of width and height for a view?

It is possible to add a ImageView inside a XML LinearLayout with the 15% of the width of the screen of width and also exactly the same height? I tried it with this dialog code which is being displayed when a user clicks on a marker on the…
1
vote
0 answers

set margin to a custom view group item view liked edittext

I am trying to create a custom view group and created it successfully but unable to set margin to an child of viewgroup like editext Following is my code, import android.content.Context; import android.support.annotation.NonNull; import…
1
vote
1 answer

How to put programmatically created Horizontally Scrolling view with XML created Layout in Android?

In my app a user can select multiple images from gallery then he can view it within the app. I have three buttons within a Relative Layout
1
vote
2 answers

How set android:layout_marginBottom programm?

To drag the Image on the screen I created my own class: private class CustomImageView extends AppCompatImageView In the constructor I want to set params: public CustomImageView(Context context) { super(context); params = new…
1
vote
1 answer

Applying LayoutParams hides the View

In the code snippet below there's one commented line. When I uncomment that line, then the contents of LinearLayout are not displayed in a TableRow. Without setting the LayoutParams, the row displays both texts. I don't understand this behavior. I…