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:br.org.funcate.dynamicforms.views.GSketchView.java

/**
 * @param noteId                the id of the note this image belows to.
 * @param fragmentDetail        the fragment detail  to use.
 * @param attrs                 attributes.
 * @param requestCode           the code for starting the activity with result.
 * @param parentView            parent/*from   ww w  . jav  a2s . c  o  m*/
 * @param label                 label
 * @param value                 value
 * @param constraintDescription constraints
 */
public GSketchView(final long noteId, final FragmentDetail fragmentDetail, AttributeSet attrs,
        final int requestCode, LinearLayout parentView, String label, String value,
        String constraintDescription) {
    super(fragmentDetail.getActivity(), attrs);
    this.noteId = noteId;

    _value = value;

    final FragmentActivity activity = fragmentDetail.getActivity();
    LinearLayout textLayout = new LinearLayout(activity);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    layoutParams.setMargins(10, 10, 10, 10);
    textLayout.setLayoutParams(layoutParams);
    textLayout.setOrientation(LinearLayout.VERTICAL);
    parentView.addView(textLayout);

    TextView textView = new TextView(activity);
    textView.setLayoutParams(
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    textView.setPadding(2, 2, 2, 2);
    textView.setText(label.replace(UNDERSCORE, " ").replace(COLON, " ") + " " + constraintDescription);
    textView.setTextColor(activity.getResources().getColor(R.color.formcolor));
    textLayout.addView(textView);

    final Button button = new Button(activity);
    button.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    button.setPadding(15, 5, 15, 5);
    button.setText(R.string.draw_sketch);
    textLayout.addView(button);

    button.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            try {
                SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
                double[] gpsLocation = PositionUtilities.getGpsLocationFromPreferences(preferences);

                Date currentDate = new Date();
                String sketchImageName = ImageUtilities.getSketchImageName(currentDate);

                File tempDir = ResourcesManager.getInstance(getContext()).getTempDir();
                File sketchFile = new File(tempDir, sketchImageName);
                /*
                 * open markers for new sketch
                 */
                MarkersUtilities.launch(fragmentDetail, sketchFile, gpsLocation, requestCode);
            } catch (Exception e) {
                //GPLog.error(this, null, e);
                Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_LONG).show();
            }
        }
    });

    ScrollView scrollView = new ScrollView(activity);
    ScrollView.LayoutParams scrollLayoutParams = new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT, 150);
    scrollView.setLayoutParams(scrollLayoutParams);
    parentView.addView(scrollView);

    imageLayout = new LinearLayout(activity);
    LinearLayout.LayoutParams imageLayoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.MATCH_PARENT);
    imageLayout.setLayoutParams(imageLayoutParams);
    // imageLayout.setMinimumHeight(200);
    imageLayout.setOrientation(LinearLayout.HORIZONTAL);
    scrollView.addView(imageLayout);
    // scrollView.setFillViewport(true);

    try {
        refresh(activity);
    } catch (Exception e) {
        //GPLog.error(this, null, e);
        Toast.makeText(this.getContext(), e.getMessage(), Toast.LENGTH_LONG).show();
    }
}

From source file:eu.hydrologis.geopaparazzi.maptools.FeaturePageAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    final Feature feature = featuresList.get(position);

    int bgColor = context.getResources().getColor(R.color.formbgcolor);
    int textColor = context.getResources().getColor(R.color.formcolor);

    ScrollView scrollView = new ScrollView(context);
    ScrollView.LayoutParams scrollLayoutParams = new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);//from   ww w . j a v a2  s  .co m
    scrollLayoutParams.setMargins(10, 10, 10, 10);
    scrollView.setLayoutParams(scrollLayoutParams);
    scrollView.setBackgroundColor(bgColor);

    LinearLayout linearLayoutView = new LinearLayout(context);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    int margin = 10;
    layoutParams.setMargins(margin, margin, margin, margin);
    linearLayoutView.setLayoutParams(layoutParams);
    linearLayoutView.setOrientation(LinearLayout.VERTICAL);
    int padding = 10;
    linearLayoutView.setPadding(padding, padding, padding, padding);
    scrollView.addView(linearLayoutView);

    List<String> attributeNames = feature.getAttributeNames();
    List<String> attributeValues = feature.getAttributeValuesStrings();
    List<String> attributeTypes = feature.getAttributeTypes();
    for (int i = 0; i < attributeNames.size(); i++) {
        final String name = attributeNames.get(i);
        String value = attributeValues.get(i);
        String typeString = attributeTypes.get(i);
        DataType type = DataType.getType4Name(typeString);

        TextView textView = new TextView(context);
        textView.setLayoutParams(
                new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
        textView.setPadding(padding, padding, padding, padding);
        textView.setText(name);
        textView.setTextColor(textColor);
        // textView.setTextAppearance(context, android.R.style.TextAppearance_Medium);

        linearLayoutView.addView(textView);

        final EditText editView = new EditText(context);
        LinearLayout.LayoutParams editViewParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                LayoutParams.WRAP_CONTENT);
        editViewParams.setMargins(margin, 0, margin, 0);
        editView.setLayoutParams(editViewParams);
        editView.setPadding(padding * 2, padding, padding * 2, padding);
        editView.setText(value);
        //            editView.setEnabled(!isReadOnly);
        editView.setFocusable(!isReadOnly);
        // editView.setTextAppearance(context, android.R.style.TextAppearance_Medium);

        if (isReadOnly) {
            editView.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    String text = editView.getText().toString();
                    FeatureUtilities.viewIfApplicable(v.getContext(), text);
                    return false;
                }
            });
        }

        switch (type) {
        case DOUBLE:
        case FLOAT:
            editView.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
            break;
        case PHONE:
            editView.setInputType(InputType.TYPE_CLASS_PHONE);
            break;
        case DATE:
            editView.setInputType(InputType.TYPE_CLASS_DATETIME);
            break;
        case INTEGER:
            editView.setInputType(InputType.TYPE_CLASS_NUMBER);
            break;
        default:
            break;
        }

        editView.addTextChangedListener(new TextWatcher() {
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                // ignore
            }

            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
                // ignore
            }

            public void afterTextChanged(Editable s) {
                String text = editView.getText().toString();
                feature.setAttribute(name, text);
            }
        });

        linearLayoutView.addView(editView);
    }

    /*
     * add also area and length
     */
    if (feature.getOriginalArea() > -1) {
        TextView areaTextView = new TextView(context);
        areaTextView.setLayoutParams(
                new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
        areaTextView.setPadding(padding, padding, padding, padding);
        areaTextView.setText("Area: " + areaLengthFormatter.format(feature.getOriginalArea()));
        areaTextView.setTextColor(textColor);
        TextView lengthTextView = new TextView(context);
        lengthTextView.setLayoutParams(
                new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
        lengthTextView.setPadding(padding, padding, padding, padding);
        lengthTextView.setText("Length: " + areaLengthFormatter.format(feature.getOriginalLength()));
        lengthTextView.setTextColor(textColor);
        linearLayoutView.addView(areaTextView);
        linearLayoutView.addView(lengthTextView);
    }
    container.addView(scrollView);

    return scrollView;
}

From source file:eu.geopaparazzi.core.maptools.FeaturePageAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    final Feature feature = featuresList.get(position);

    int bgColor = Compat.getColor(context, eu.geopaparazzi.library.R.color.formbgcolor);
    int textColor = Compat.getColor(context, eu.geopaparazzi.library.R.color.formcolor);

    ScrollView scrollView = new ScrollView(context);
    ScrollView.LayoutParams scrollLayoutParams = new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);/*from w  w  w. j  a  v a 2s .c om*/
    scrollLayoutParams.setMargins(10, 10, 10, 10);
    scrollView.setLayoutParams(scrollLayoutParams);
    scrollView.setBackgroundColor(bgColor);

    LinearLayout linearLayoutView = new LinearLayout(context);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    int margin = 10;
    layoutParams.setMargins(margin, margin, margin, margin);
    linearLayoutView.setLayoutParams(layoutParams);
    linearLayoutView.setOrientation(LinearLayout.VERTICAL);
    int padding = 10;
    linearLayoutView.setPadding(padding, padding, padding, padding);
    scrollView.addView(linearLayoutView);

    List<String> attributeNames = feature.getAttributeNames();
    List<String> attributeValues = feature.getAttributeValuesStrings();
    List<String> attributeTypes = feature.getAttributeTypes();
    for (int i = 0; i < attributeNames.size(); i++) {
        final String name = attributeNames.get(i);
        String value = attributeValues.get(i);
        String typeString = attributeTypes.get(i);
        EDataType type = EDataType.getType4Name(typeString);

        TextView textView = new TextView(context);
        textView.setLayoutParams(
                new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
        textView.setPadding(padding, padding, padding, padding);
        textView.setText(name);
        textView.setTextColor(textColor);
        // textView.setTextAppearance(context, android.R.style.TextAppearance_Medium);

        linearLayoutView.addView(textView);

        final TextView editView = getEditView(feature, name, type, value);
        LinearLayout.LayoutParams editViewParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                LayoutParams.WRAP_CONTENT);
        editViewParams.setMargins(margin, 0, margin, 0);
        editView.setLayoutParams(editViewParams);
        editView.setPadding(padding * 2, padding, padding * 2, padding);
        editView.setFocusable(!isReadOnly);

        if (isReadOnly) {
            editView.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    String text = editView.getText().toString();
                    FeatureUtilities.viewIfApplicable(v.getContext(), text);
                    return false;
                }
            });
        }
        linearLayoutView.addView(editView);
    }

    /*
     * add also area and length
     */
    if (feature.getOriginalArea() > -1) {
        TextView areaTextView = new TextView(context);
        areaTextView.setLayoutParams(
                new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
        areaTextView.setPadding(padding, padding, padding, padding);
        areaTextView.setText(context.getString(eu.geopaparazzi.core.R.string.area_colon)
                + areaLengthFormatter.format(feature.getOriginalArea()));
        areaTextView.setTextColor(textColor);
        TextView lengthTextView = new TextView(context);
        lengthTextView.setLayoutParams(
                new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
        lengthTextView.setPadding(padding, padding, padding, padding);
        lengthTextView.setText(context.getString(eu.geopaparazzi.core.R.string.length_colon)
                + areaLengthFormatter.format(feature.getOriginalLength()));
        lengthTextView.setTextColor(textColor);
        linearLayoutView.addView(areaTextView);
        linearLayoutView.addView(lengthTextView);
    }
    container.addView(scrollView);

    return scrollView;
}

From source file:org.telegram.ui.ChangePhoneHelpActivity.java

@Override
public View createView(Context context) {
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);

    TLRPC.User user = UserConfig.getCurrentUser();
    String value;// ww  w .  j  ava  2  s .co  m
    if (user != null && user.phone != null && user.phone.length() != 0) {
        value = PhoneFormat.getInstance().format("+" + user.phone);
    } else {
        value = LocaleController.getString("NumberUnknown", R.string.NumberUnknown);
    }

    actionBar.setTitle(value);
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            }
        }
    });

    fragmentView = new RelativeLayout(context);
    fragmentView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });

    RelativeLayout relativeLayout = (RelativeLayout) fragmentView;

    ScrollView scrollView = new ScrollView(context);
    relativeLayout.addView(scrollView);
    RelativeLayout.LayoutParams layoutParams3 = (RelativeLayout.LayoutParams) scrollView.getLayoutParams();
    layoutParams3.width = LayoutHelper.MATCH_PARENT;
    layoutParams3.height = LayoutHelper.WRAP_CONTENT;
    layoutParams3.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
    scrollView.setLayoutParams(layoutParams3);

    LinearLayout linearLayout = new LinearLayout(context);
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    linearLayout.setPadding(0, AndroidUtilities.dp(20), 0, AndroidUtilities.dp(20));
    scrollView.addView(linearLayout);
    ScrollView.LayoutParams layoutParams = (ScrollView.LayoutParams) linearLayout.getLayoutParams();
    layoutParams.width = ScrollView.LayoutParams.MATCH_PARENT;
    layoutParams.height = ScrollView.LayoutParams.WRAP_CONTENT;
    linearLayout.setLayoutParams(layoutParams);

    ImageView imageView = new ImageView(context);
    imageView.setImageResource(R.drawable.phone_change);
    linearLayout.addView(imageView);
    LinearLayout.LayoutParams layoutParams2 = (LinearLayout.LayoutParams) imageView.getLayoutParams();
    layoutParams2.width = LayoutHelper.WRAP_CONTENT;
    layoutParams2.height = LayoutHelper.WRAP_CONTENT;
    layoutParams2.gravity = Gravity.CENTER_HORIZONTAL;
    imageView.setLayoutParams(layoutParams2);

    TextView textView = new TextView(context);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    textView.setGravity(Gravity.CENTER_HORIZONTAL);
    //textView.setTextColor(0xff212121);

    try {
        textView.setText(AndroidUtilities
                .replaceTags(LocaleController.getString("PhoneNumberHelp", R.string.PhoneNumberHelp)));
    } catch (Exception e) {
        FileLog.e("tmessages", e);
        textView.setText(LocaleController.getString("PhoneNumberHelp", R.string.PhoneNumberHelp));
    }
    linearLayout.addView(textView);
    layoutParams2 = (LinearLayout.LayoutParams) textView.getLayoutParams();
    layoutParams2.width = LayoutHelper.WRAP_CONTENT;
    layoutParams2.height = LayoutHelper.WRAP_CONTENT;
    layoutParams2.gravity = Gravity.CENTER_HORIZONTAL;
    layoutParams2.leftMargin = AndroidUtilities.dp(20);
    layoutParams2.rightMargin = AndroidUtilities.dp(20);
    layoutParams2.topMargin = AndroidUtilities.dp(56);
    textView.setLayoutParams(layoutParams2);

    textView = new TextView(context);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    textView.setGravity(Gravity.CENTER_HORIZONTAL);
    textView.setTextColor(ContextCompat.getColor(context, R.color.colorAccent) /*0xff4d83b3*/);
    textView.setText(LocaleController.getString("PhoneNumberChange", R.string.PhoneNumberChange));
    textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    textView.setPadding(AndroidUtilities.dp(16), AndroidUtilities.dp(12), AndroidUtilities.dp(16),
            AndroidUtilities.dp(12));
    textView.setBackground(context.getDrawable(R.drawable.list_selector));
    linearLayout.addView(textView);
    layoutParams2 = (LinearLayout.LayoutParams) textView.getLayoutParams();
    layoutParams2.width = LayoutHelper.WRAP_CONTENT;
    layoutParams2.height = LayoutHelper.WRAP_CONTENT;
    layoutParams2.gravity = Gravity.CENTER_HORIZONTAL;
    layoutParams2.leftMargin = AndroidUtilities.dp(20);
    layoutParams2.rightMargin = AndroidUtilities.dp(20);
    layoutParams2.topMargin = AndroidUtilities.dp(46);
    textView.setLayoutParams(layoutParams2);

    textView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (getParentActivity() == null) {
                return;
            }
            AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
            builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
            builder.setMessage(LocaleController.getString("PhoneNumberAlert", R.string.PhoneNumberAlert));
            builder.setPositiveButton(LocaleController.getString("OK", R.string.OK),
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                            presentFragment(new ChangePhoneActivity(), true);
                        }
                    });
            builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
            showDialog(builder.create());
        }
    });

    return fragmentView;
}

From source file:info.semanticsoftware.semassist.android.activity.SemanticAssistantsActivity.java

/** Presents additional information about a specific assistant.
 * @return a dynamically generated linear layout
 *///w w w. j  a  v  a 2 s  .c o  m
private LinearLayout getServiceDescLayout() {
    final LinearLayout output = new LinearLayout(this);
    final RelativeLayout topButtonsLayout = new RelativeLayout(this);
    RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);

    final Button btnBack = new Button(this);
    btnBack.setText(R.string.btnAllServices);
    btnBack.setId(5);
    btnBack.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            output.setVisibility(View.GONE);
            getListView().setVisibility(View.VISIBLE);
            lblAvAssist.setVisibility(View.VISIBLE);
        }
    });

    topButtonsLayout.addView(btnBack);

    final Button btnInvoke = new Button(this);
    btnInvoke.setText(R.string.btnInvokeLabel);
    btnInvoke.setId(6);

    btnInvoke.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            new InvocationTask().execute();
        }
    });

    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, btnInvoke.getId());
    btnInvoke.setLayoutParams(layoutParams);
    topButtonsLayout.addView(btnInvoke);

    output.addView(topButtonsLayout);

    TableLayout serviceInfoTbl = new TableLayout(this);
    output.addView(serviceInfoTbl);

    serviceInfoTbl.setColumnShrinkable(1, true);

    /* FIRST ROW */
    TableRow rowServiceName = new TableRow(this);

    TextView lblServiceName = new TextView(this);
    lblServiceName.setText(R.string.lblServiceName);
    lblServiceName.setTextAppearance(getApplicationContext(), R.style.titleText);

    TextView txtServiceName = new TextView(this);
    txtServiceName.setText(selectedService);
    txtServiceName.setTextAppearance(getApplicationContext(), R.style.normalText);
    txtServiceName.setPadding(10, 0, 0, 0);

    rowServiceName.addView(lblServiceName);
    rowServiceName.addView(txtServiceName);

    /* SECOND ROW */
    TableRow rowServiceDesc = new TableRow(this);

    TextView lblServiceDesc = new TextView(this);
    lblServiceDesc.setText(R.string.lblServiceDesc);
    lblServiceDesc.setTextAppearance(getApplicationContext(), R.style.titleText);

    TextView txtServiceDesc = new TextView(this);
    txtServiceDesc.setTextAppearance(getApplicationContext(), R.style.normalText);
    txtServiceDesc.setPadding(10, 0, 0, 0);
    List<GateRuntimeParameter> params = null;
    ServiceInfoForClientArray list = getServices();
    for (int i = 0; i < list.getItem().size(); i++) {
        if (list.getItem().get(i).getServiceName().equals(selectedService)) {
            txtServiceDesc.setText(list.getItem().get(i).getServiceDescription());
            params = list.getItem().get(i).getParams();
            break;
        }
    }

    TextView lblParams = new TextView(this);
    lblParams.setText(R.string.lblServiceParams);
    lblParams.setTextAppearance(getApplicationContext(), R.style.titleText);
    output.addView(lblParams);

    LayoutParams txtParamsAttrbs = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
    LinearLayout paramsLayout = new LinearLayout(this);
    paramsLayout.setId(0);

    if (params.size() > 0) {
        ScrollView scroll = new ScrollView(this);
        scroll.setLayoutParams(txtParamsAttrbs);
        paramsLayout.setOrientation(LinearLayout.VERTICAL);
        scroll.addView(paramsLayout);
        for (int j = 0; j < params.size(); j++) {
            TextView lblParamName = new TextView(this);
            lblParamName.setText(params.get(j).getParamName());
            EditText tview = new EditText(this);
            tview.setId(1);
            tview.setText(params.get(j).getDefaultValueString());
            LayoutParams txtViewLayoutParams = new LayoutParams(LayoutParams.FILL_PARENT,
                    LayoutParams.WRAP_CONTENT);
            tview.setLayoutParams(txtViewLayoutParams);
            paramsLayout.addView(lblParamName);
            paramsLayout.addView(tview);
        }
        output.addView(scroll);
    } else {
        TextView lblParamName = new TextView(this);
        lblParamName.setText(R.string.lblRTParams);
        output.addView(lblParamName);
    }

    rowServiceDesc.addView(lblServiceDesc);
    rowServiceDesc.addView(txtServiceDesc);

    serviceInfoTbl.addView(rowServiceName);
    serviceInfoTbl.addView(rowServiceDesc);

    output.setOrientation(LinearLayout.VERTICAL);
    output.setGravity(Gravity.TOP);

    return output;
}

From source file:com.appfirst.activities.details.AFServerDetail.java

/**
 * @return//from  w  w w . j  ava2s .  co  m
 */
private ScrollView createOuterContainer() {
    ScrollView container = new ScrollView(this);
    container.setVerticalScrollBarEnabled(true);
    container.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, this.dialogMaxInnerSpace));

    return container;
}

From source file:br.org.funcate.dynamicforms.views.GPictureView.java

/**
 * @param fragmentDetail        the fragment detail  to use.
 * @param attrs                 attributes.
 * @param requestCode           the code for starting the activity with result.
 * @param parentView            parent/*from   w  w w  .j a  va2 s .  com*/
 * @param label                 label
 * @param pictures              the value are the ids and binary data of the images.
 * @param constraintDescription constraints
 */
public GPictureView(final FragmentDetail fragmentDetail, AttributeSet attrs, final int requestCode,
        LinearLayout parentView, String label, Map<String, Map<String, String>> pictures,
        String constraintDescription) {
    super(fragmentDetail.getActivity(), attrs);

    thumbnailWidth = fragmentDetail.getActivity().getResources().getInteger(R.integer.thumbnail_width);
    thumbnailHeight = fragmentDetail.getActivity().getResources().getInteger(R.integer.thumbnail_height);

    mFragmentDetail = fragmentDetail;

    _pictures = pictures;

    PICTURE_VIEW_RESULT = requestCode;

    final FragmentActivity activity = fragmentDetail.getActivity();
    LinearLayout textLayout = new LinearLayout(activity);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    layoutParams.setMargins(10, 10, 10, 10);
    textLayout.setPadding(10, 5, 10, 5);
    textLayout.setLayoutParams(layoutParams);
    textLayout.setOrientation(LinearLayout.VERTICAL);
    parentView.addView(textLayout);

    TextView textView = new TextView(activity);
    textView.setLayoutParams(
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    textView.setPadding(2, 2, 2, 2);
    String t = label.replace(UNDERSCORE, " ").replace(COLON, " ") + " " + constraintDescription;
    textView.setText(t);
    textView.setTextColor(activity.getResources().getColor(R.color.formcolor));
    textLayout.addView(textView);

    final Button button = new Button(activity);
    button.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    button.setPadding(15, 5, 15, 5);
    button.setText(R.string.take_picture);
    textLayout.addView(button);

    button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            Intent cameraIntent = new Intent(activity, CameraActivity.class);

            cameraIntent.putExtra(FormUtilities.MAIN_APP_WORKING_DIRECTORY,
                    fragmentDetail.getWorkingDirectory());

            fragmentDetail.startActivityForResult(cameraIntent, requestCode);
        }
    });

    ScrollView scrollView = new ScrollView(activity);
    ScrollView.LayoutParams scrollLayoutParams = new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    scrollView.setLayoutParams(scrollLayoutParams);
    scrollView.setHorizontalScrollBarEnabled(true);
    scrollView.setOverScrollMode(HorizontalScrollView.OVER_SCROLL_ALWAYS);
    parentView.addView(scrollView);

    imageLayout = new LinearLayout(activity);
    LinearLayout.LayoutParams imageLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT);
    imageLayout.setLayoutParams(imageLayoutParams);
    imageLayout.setPadding(15, 5, 15, 5);
    imageLayout.setOrientation(LinearLayout.HORIZONTAL);
    imageLayout.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
    scrollView.addView(imageLayout);

    updateValueForm();
    try {
        refresh(activity);
    } catch (Exception e) {
        //GPLog.error(this, null, e);
        e.printStackTrace();
        Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_LONG).show();
    }
}

From source file:org.openremote.android.console.AppSettingsActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setTitle(R.string.settings);/*from  w w  w  . ja va  2 s  . co m*/

    this.autoMode = AppSettingsModel.isAutoMode(AppSettingsActivity.this);

    // The main layout contains all application configuration items.
    LinearLayout mainLayout = new LinearLayout(this);
    mainLayout
            .setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    mainLayout.setOrientation(LinearLayout.VERTICAL);
    mainLayout.setBackgroundColor(0);
    mainLayout.setTag(R.string.settings);

    loadingPanelProgress = new ProgressDialog(this);

    // The scroll view contains appSettingsView, and make the appSettingsView can be scrolled.
    ScrollView scroll = new ScrollView(this);
    scroll.setVerticalScrollBarEnabled(true);
    scroll.setLayoutParams(
            new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 1));
    appSettingsView = new LinearLayout(this);
    appSettingsView
            .setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    appSettingsView.setOrientation(LinearLayout.VERTICAL);

    appSettingsView.addView(createAutoLayout());
    appSettingsView.addView(createChooseControllerLabel());

    currentServer = "";
    if (autoMode) {
        appSettingsView.addView(constructAutoServersView());
    } else {
        appSettingsView.addView(constructCustomServersView());
    }
    appSettingsView.addView(createChoosePanelLabel());
    panelSelectSpinnerView = new PanelSelectSpinnerView(this);
    appSettingsView.addView(panelSelectSpinnerView);

    appSettingsView.addView(createCacheText());
    appSettingsView.addView(createClearImageCacheButton());
    appSettingsView.addView(createSSLLayout());
    scroll.addView(appSettingsView);

    mainLayout.addView(scroll);
    mainLayout.addView(createDoneAndCancelLayout());

    setContentView(mainLayout);
    initSSLState();
    addOnclickListenerOnDoneButton();
    addOnclickListenerOnCancelButton();
    progressLayout = (LinearLayout) findViewById(R.id.choose_controller_progress);

}

From source file:com.juick.android.MainActivity.java

@TargetApi(VERSION_CODES.ICE_CREAM_SANDWICH)
private void selectSourcesForCombined(final String prefix, final String[] codes) {
    final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
    ScrollView v = new ScrollView(this);
    v.setLayoutParams(new ScrollView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    final LinearLayout ll = new LinearLayout(this);
    ll.setLayoutParams(new ScrollView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    ll.setOrientation(LinearLayout.VERTICAL);
    v.addView(ll);/* ww  w . ja v  a  2 s.  c om*/
    for (int i = 0; i < codes.length; i++) {
        final CompoundButton sw = VERSION.SDK_INT >= 14 ? new Switch(this) : new CheckBox(this);
        sw.setPadding(10, 10, 10, 10);
        sw.setLayoutParams(new ScrollView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
        sw.setText(codes[i]);
        sw.setChecked(sp.getBoolean(prefix + codes[i], true));
        ll.addView(sw);
    }

    new AlertDialog.Builder(MainActivity.this).setView(v).setCancelable(true)
            .setOnCancelListener(new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialogInterface) {
                    SharedPreferences.Editor e = sp.edit();
                    for (int i = 0; i < ll.getChildCount(); i++) {
                        CompoundButton cb = (CompoundButton) ll.getChildAt(i);
                        assert cb != null;
                        e.putBoolean(prefix + codes[i], cb.isChecked());
                    }
                    e.commit();
                }
            }).create().show();

}

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

@Override
public void SliderDragDragging(int whereY) {
    Display display = getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);//w ww.  ja  v  a 2  s . c om
    int height = size.y;

    if (fragmentEditField != null) {
        ScrollView sv = (ScrollView) fragmentEditField.getView().findViewById(R.id.slider_scrollView);
        RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) sv.getLayoutParams();

        if ((height - whereY - sliderStartDrag) > 0) {
            params.height = height - whereY - sliderStartDrag;
        } else {
            params.height = 0;
        }
        sv.setLayoutParams(params);
    }
}