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

recyclerView different spacing between items using scale

Horizontal recyclerView (DiscreteScrollView library) with scaling set to 50% between selected view and others doesn't keep spacing the same. Example below shows that spacing between 1/2 and 4/5 are more spacious than views next to currently selected…
ashaneen
  • 137
  • 1
  • 15
0
votes
1 answer

radiobutton set layoutparams do not work when be add to radiogroup

val param = LinearLayout.LayoutParams(WRAP_CONTENT,WRAP_CONTENT) param.rightMargin = 100 val rb = RadioButton(this) rb.text = "1" rb.setTextColor(Color.parseColor("#ffffff")) rb.layoutParams = param …
jaygee
  • 25
  • 3
0
votes
0 answers

Hide Notch grey background when launching splash screen

For react-native app on Android For the devices with Notch - I am able to use full screen mode on all screens except Splash screen by this code : This code basically uses full screen even behind the notch. if (Build.VERSION.SDK_INT >=…
newdeveloper
  • 1,401
  • 3
  • 17
  • 43
0
votes
0 answers

Custom ViewGroup LayoutParams not working in android

Well I m just learning custom viewgroups in android so i have made a simple viewgroup. i named it LearnLayout i have custom layoutparam in it, called as LearnLayoutParams Problem when i use custom attributes on children. those attributes are not…
0
votes
0 answers

How to change view size without calling requestLayout()

I'm developing a game which has a lot of views in a layout. Each game loop (33ms) one of the views is changing it's size, so I do this on the LayoutParams variable applied on the View on each loop with the new size. params.width =…
NullPointerException
  • 36,107
  • 79
  • 222
  • 382
0
votes
1 answer

Button to update layout_weight doesn't take effect

I am using this code in kotlin to update the layout_weight of a linear_layout as an indication. When the button is pressed though, the layout weight doesn't change. This will eventually be a fun app using random updates but for now I want to make…
edwind
  • 3
  • 3
0
votes
1 answer

getLocationInWindow not change after change LayoutParams

I have a view like this: I get the global position twice. Before changing the view size and After changing the view size. CODE: private void getViewPosition(View view){ …
Pablo Garcia
  • 361
  • 6
  • 23
0
votes
3 answers

addRule in RelativeLayout.LayoutParams is not working

I have this code: final RelativeLayout headerRl=new RelativeLayout(SpeakersActivity.this); headerRl.setBackgroundColor(Color.parseColor(almacen.getColor())); final TextView initial=new TextView(SpeakersActivity.this); …
Fustigador
  • 6,339
  • 12
  • 59
  • 115
0
votes
2 answers

GridView looking similar in every device

I need to know how to set the LayoutParam according to the resolution of the mobile phones.. Im using a GridView where I'm using GridView.LayoutParams(45, 45).. Now if I'm using mobile with small screen size is ok.. But if I test with the big screen…
Hussain
  • 5,552
  • 4
  • 40
  • 50
0
votes
1 answer

Android RelativeLayout: Show a list of ConstraintLayouts

I have a ConstraintLayout file called R.layout.new_plan which contains the Views needed to display a PlanItem object. I'd like to display a list of R.layout.new_plan's in a RelativeLayout root view. My RelativeLayout parent/root is like…
Fawwaz Yusran
  • 1,260
  • 2
  • 19
  • 36
0
votes
1 answer

Gravity not set properlywith LayoutParams in onBindViewHolder

I have a chat activity that is arranging messages based on the username of the sender. All of the behavior outlined in onBindViewHolder is working properly, except for the Gravity of the container (all messages are aligning end when they should be…
andrewedgar
  • 797
  • 1
  • 12
  • 46
0
votes
3 answers

RelativeLayout LayoutParams incorrect scaling

I have a Relative Layout within an XML file with an ImageView element which contains both width and height for an image.
0
votes
1 answer

How to draw view over the lock screen in oreo?

This my code. I am trying to draw a view on lock screen. It works perfectly fine on android 7.1 but when i run this on oreo, it doesn't work (view cannot appear on lock screen but when you unlock the screen then view comes and service stopped)…
0
votes
1 answer

When generating new views they are stacking on top of each other

When I click my button for adding new buttons to a framelayout, the new buttons are stacking on top of each other. Any idea what I'm doing wrong? public void onClick(View v) { Button newAlarm = new Button(Hop_Timer.this); …
OFlan
  • 43
  • 1
  • 6
0
votes
1 answer

LayoutParams.MATCH_PARENT does not work but integer does

I am generating editTexts in a TableRow and the editTexts width is wrapping the content by default. I tried to set their width to match_parent like this: TableRow tr = new TableRow(getActivity()); EditText et = new…
Readdeo
  • 1
  • 1