How to change ListView height dynamically in Android?
for change height and width dynamically so, try this
RelativeLayout.LayoutParams mParam = new RelativeLayout.LayoutParams((int)(width),(int)(height);
listView.setLayoutParams(mParam);
you can also use LayoutParams.FILL_PARENT or LayoutParams.WRAP_CONTENT instead of height & width
Set ListView Height dynamically based on multiline textview inside it
As Teemu mentions you need to constrain the width. Sample code below.
float px = 300 * (listView.getResources().getDisplayMetrics().density);
item.measure(View.MeasureSpec.makeMeasureSpec((int)px, View.MeasureSpec.AT_MOST), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
Change Height of a Listview dynamicallyAndroid
If you want to change the height of list view dynamically, you could use,
list.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, theSizeIWant));
Related Topics
How to Close the Current Fragment by Using Button Like the Back Button
How to Get Context in Android Mvvm Viewmodel
How to Open Draw Overlay Permission Popup in Miui
How to Keep a Bottom Nav Bar from Being Pushed Up on Keyboard Shown
Adb.Exe Not Found After Installing Android Studio
How to Use Python to Execute Adb Commands
How to Check If a Value Exists Already in a Firebase Data Class Android
How to Go Back to Previous Fragment from Activity
Why Livedata Observer Is Being Triggered Twice for a Newly Attached Observer
How to Start an Activity from Background in Android 10
Suppress Keyboard from Popping Up
Changing Cardview Shadow Color
Get City Name and Postal Code from Google Place API on Android
How to Verify Purchase for Android App in Server Side (Google Play in App Billing V3)
Error Androidmanifest.Xml Doesn't Exist or Has Incorrect Root Tag
Android Studio - Xml Editor Autocomplete Not Working With Support Libraries