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
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
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…
1
vote
2 answers

Dialog fragment not occupying complete screen

I am opening dialog fragment. However, it does not occupy entire screen. I mean it leaves some space all side. Below is my code : public class MyDialogFragment extends DialogFragment implements View.OnClickListener{ private Context…
1
vote
1 answer

Animate LayoutParams LeftMargin and TopMargin

I've read on how to do this in Android, but I cannot seem to find the Xamarin Android equivalent to animating a Layout's LeftMargin and TopMargin. Obviously Xamarin has "Animation", but I can't figure out the "applyTransformation" part of this in…
1
vote
1 answer

How to align a rotated layout to right and match parent height?

I am going to create a layout with a status bar on the right I tried to use xml, but this is not work, the bar cannot align to right, and the textview is not in the relativelayout after rotation.
1
vote
1 answer

How to put a AdMob banner below a view with MATCH_PARENT height?

I have a ViewPager with a PagerTitleStrip which has MATCH_PARENT height. The pages has only some text, but some pages have vertical scroll because the text is very long. Now I'm trying to find the best strategy to put an AdMob banner in the bottom…
1
vote
2 answers

How to make Dialog's width match screen width

I want to create a Dialog with custom layout. I want it's width to be same as the phone screen's width and height as WRAP_CONTENT. Here is what I tried: Dialog dialog = new Dialog(context, R.style.DialogSlideAnim); …
Amit Tiwari
  • 3,684
  • 6
  • 33
  • 75
1
vote
2 answers

Evenly spacing buttons with layout_weight but having a maxWidth

I have 4 buttons that I space out evenly using layout_weight="1" and layout_width="0dp". However, on large tablet layouts the buttons are too spread out and looks ugly, so I want to set a maxWidth for all of them, and having empty spaces on both…
1
vote
1 answer

How to add and remove layout behavior programmatically to LinearLayout

You can add the app:layout_behavior="@string/appbar_scrolling_view_behavior" behavior to a LinearLayout in the XML declaration but I haven't found a way to do the same in code. With a CoordinatorLayout you can call…
Aspiring Dev
  • 505
  • 1
  • 4
  • 17
1
vote
1 answer

Purpose of ALPHA_CHANGED in Android

In WindowManager.LayoutParams class there is a constant called ALPHA_CHANGED. What is the purpose of it? I can't seem to find anything about it.
dreamcoder
  • 1,233
  • 1
  • 11
  • 25
1
vote
1 answer

Why does Material Design Toolbar have this strange padding?

In my ToolBar with android:padding=0dp, and in it I have a single LinearLayout with android:width=match_parent and android:layout_marginLeft="0dp". So at least width-wise, no part of the Toolbar (colored black in this example) should show on the…
1
vote
2 answers

How to know which LayoutParams class to use when creating a View programmatically?

Every ViewGroup class implements a nested class that extends ViewGroup.LayoutParams. So we LinearLayout.LayoutParams, RelativeLayout.LayoutParams, FrameLayout.LayoutParams etc. Suppose I want to create a View, e.g. TextView programmatically. I will…
1
vote
1 answer

How can I put programmatically my imageView center_veritically on a FrameLayout?

I want to put an imageView on the center_vertically of FrameLayout. But, I can not do it. I have tried FrameLayout.LayoutParams but, it does not have .addRule() method. public class P023Deneme extends Activity { @Override protected void…
1 2 3
8 9