Example usage for android.widget ScrollView setLayoutParams

List of usage examples for android.widget ScrollView setLayoutParams

Introduction

In this page you can find the example usage for android.widget ScrollView setLayoutParams.

Prototype

public void setLayoutParams(ViewGroup.LayoutParams params) 

Source Link

Document

Set the layout parameters associated with this view.

Usage

From source file:com.mobicage.rogerthat.plugins.messaging.widgets.AdvancedOrderWidget.java

private void setDetailScrollViewHeight() {
    final Point displaySize = UIUtils.getDisplaySize(mActivity);
    final TextView nameLbl = (TextView) mDetailDialog.findViewById(R.id.name);
    final TextView priceLbl = (TextView) mDetailDialog.findViewById(R.id.price);
    final ScrollView scrollView = (ScrollView) mDetailDialog.findViewById(R.id.scroll_view);
    final LinearLayout valueContainer = (LinearLayout) mDetailDialog.findViewById(R.id.value_container);
    final Button dismissBtn = (Button) mDetailDialog.findViewById(R.id.dismiss);
    int maxPopupHeight = (int) Math.floor(displaySize.y * 0.75);

    int desiredWidth = MeasureSpec.makeMeasureSpec(nameLbl.getWidth(), MeasureSpec.AT_MOST);

    nameLbl.measure(desiredWidth, 0);/*from   w w w. java  2s  . c  o m*/
    int nameLblHeight = nameLbl.getMeasuredHeight();
    int priceLblHeight = 0;
    if (priceLbl.getVisibility() == View.VISIBLE) {
        priceLbl.measure(desiredWidth, 0);
        priceLblHeight = priceLbl.getMeasuredHeight();
    }
    valueContainer.measure(desiredWidth, 0);
    int valueContainerHeight = valueContainer.getMeasuredHeight();
    dismissBtn.measure(desiredWidth, 0);
    int dismissBtnHeight = dismissBtn.getMeasuredHeight();

    int maxScrollViewHeight = maxPopupHeight - nameLblHeight - priceLblHeight - valueContainerHeight
            - dismissBtnHeight;

    ViewGroup.LayoutParams params = scrollView.getLayoutParams();
    scrollView.measure(desiredWidth, 0);
    params.height = scrollView.getMeasuredHeight();
    if (maxScrollViewHeight > 0 && params.height > maxScrollViewHeight) {
        params.height = maxScrollViewHeight;
    }
    scrollView.setLayoutParams(params);
    scrollView.requestLayout();
}

From source file:com.openatk.planting.MainActivity.java

private void SliderGrow() {
    Display display = getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);/*w  w w.  jav a 2s  .c  o  m*/
    int oneThirdHeight = size.y / 3;
    int actionBarHeight = 10;
    TypedValue tv = new TypedValue();
    if (getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
        actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics());
    }
    if (fragmentEditField != null) {
        RelativeLayout relAdd = (RelativeLayout) fragmentEditField.getView().findViewById(R.id.slider_layMenu);
        RelativeLayout relBottomBar = (RelativeLayout) fragmentEditField.getView()
                .findViewById(R.id.edit_field_layInfo3);
        Log.d("layMenu:", Integer.toString(relAdd.getHeight()));
        ScrollView sv = (ScrollView) fragmentEditField.getView().findViewById(R.id.slider_scrollView);
        RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) sv.getLayoutParams();
        if (sliderPosition == 0) {
            //Small -> Middle
            DropDownAnim an = new DropDownAnim(sv, params.height, oneThirdHeight);
            an.setDuration(300);
            sv.startAnimation(an);
            sliderPosition = 1;
        } else if (sliderPosition == 1) {
            //Middle -> Fullscreen
            DropDownAnim an = new DropDownAnim(sv, params.height,
                    (fragMap.getView().getHeight() - relAdd.getHeight() - relBottomBar.getHeight()));
            Log.d("fullslider", "Full slider" + Integer.toString(relBottomBar.getHeight()));

            an.setDuration(300);
            sv.startAnimation(an);
            sliderPosition = 2;
        }
        sv.setLayoutParams(params);
    }
}

From source file:com.openatk.planting.MainActivity.java

private void SliderShrink() {
    Display display = getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);/*ww  w  . j ava  2 s  . co  m*/
    int oneThirdHeight = (size.y / 3);

    if (fragmentEditField != null) {
        ScrollView sv = (ScrollView) fragmentEditField.getView().findViewById(R.id.slider_scrollView);
        RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) sv.getLayoutParams();
        if (sliderPosition == 1) {
            //Middle -> Small
            DropDownAnim an = new DropDownAnim(sv, params.height, 0);
            an.setDuration(300);
            sv.startAnimation(an);
            sliderPosition = 0;
        } else if (sliderPosition == 2) {
            //Fullscreen -> Middle if has notes
            //Fullscreen -> Small if no notes
            if (false) {
                DropDownAnim an = new DropDownAnim(sv, params.height, oneThirdHeight);
                an.setDuration(300);
                sv.startAnimation(an);
                sliderPosition = 1;
            } else {
                DropDownAnim an = new DropDownAnim(sv, params.height, 0);
                an.setDuration(300);
                sv.startAnimation(an);
                sliderPosition = 0;
            }
        }
        sv.setLayoutParams(params);
    }
}