You can pass it in as part of the LinearLayout.LayoutParams
constructor:
LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT,
1.0f
);
YOUR_VIEW.setLayoutParams(param);
The last parameter is the weight.
More Related Contents:
- What is android:weightSum in android, and how does it work?
- Can anyone solve my Android Fragment issue? [closed]
- How to define dimens.xml for every different screen size in android?
- How to dismiss the dialog with click on outside of the dialog?
- How to put a border around an Android TextView?
- adjustPan not preventing keyboard from covering EditText
- What’s “tools:context” in Android layout files?
- How can I globally force screen orientation in Android?
- FragmentContainerView using findNavController
- Dynamic form with repeating form
- What is the purpose of Android’s tag in XML layouts?
- Spinner does not wrap text — is this an Android bug?
- How to Automatically add thousand separators as number is input in EditText
- How to wrap the height of a ViewPager to the height of its current Fragment?
- How To Show and hide ActionBar with AppCompat v.7
- android activity has leaked window com.android.internal.policy.impl.phonewindow$decorview Issue
- How to capture and save an image using custom camera in Android?
- How can I change font size in PreferenceScreen
- Page scroll when soft keyboard popped up
- Android: ScrollView vs NestedScrollView
- How to remove focus without setting focus to another control?
- The specified child already has a parent. You must call removeView() on the child’s parent first
- Difference between android: and app: prefix in Android XML?
- How to extract the text from the selected item on the listView
- Android LinearLayout Gradient Background
- TextWatcher events are being fired multiple times
- InflateException: Binary XML file line #8: Error inflating class ImageView
- New Android Design Library bug with AppBarLayout and Toolbar
- Android Studio Project: bottom of UI is cut off
- Android – use external profile image in notification bar like Facebook