I solved this problem. set the weight "1" of the layout in the XML file (in my case the XML is the same as above), it will work if the Screen size is large and also checked grammatically, if the size of the view is less than the minimum size, then set the height of the view grammatically . Sample Code: -
Install ViewTreeObserver to view: -
lytSpeakerDetails = (RelativeLayout) view.findViewById(R.id.lytSpeakerDetails); ViewTreeObserver viewTreeObserver = lytSpeakerDetails.getViewTreeObserver(); viewTreeObserver.addOnGlobalLayoutListener(globalLayoutListener);
and in the Listener callback, check if the minimum layout height is smaller, and then set the height to minimum: -
ViewTreeObserver.OnGlobalLayoutListener globalLayoutListener = new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { if (!isAdded()) return; lytSpeakerDetails.getViewTreeObserver().removeGlobalOnLayoutListener(this); int height = lytSpeakerDetails.getMeasuredHeight(); LinearLayout.LayoutParams imgViewParams = (LinearLayout.LayoutParams) lytSpeakerDetails.getLayoutParams(); if(height < (int)getResources().getDimension(R.dimen.brightness_minimum_height)) { LinearLayout.LayoutParams rel_btn = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, (int) getResources().getDimension(R.dimen.brightness_minimum_height)); lytSpeakerDetails.setLayoutParams(rel_btn); } } };
Hradesh kumar
source share