Example usage for android.view ViewGroup getLayoutParams

List of usage examples for android.view ViewGroup getLayoutParams

Introduction

In this page you can find the example usage for android.view ViewGroup getLayoutParams.

Prototype

@ViewDebug.ExportedProperty(deepExport = true, prefix = "layout_")
public ViewGroup.LayoutParams getLayoutParams() 

Source Link

Document

Get the LayoutParams associated with this view.

Usage

From source file:com.haibison.android.anhuu.FragmentFiles.java

/**
 * Setup:/*from  w w  w. jav  a 2 s  .  c om*/
 * <p/>
 * <ul>
 * <li>button Cancel;</li>
 * <li>text field "save as" filename;</li>
 * <li>button OK;</li>
 * </ul>
 */
private void setupFooter() {
    /*
     * By default, view group footer and all its child views are hidden.
     */

    ViewGroup viewGroupFooterContainer = (ViewGroup) getView()
            .findViewById(R.id.anhuu_f5be488d_viewgroup_footer_container);
    ViewGroup viewGroupFooter = (ViewGroup) getView().findViewById(R.id.anhuu_f5be488d_viewgroup_footer);

    if (mIsSaveDialog) {
        viewGroupFooterContainer.setVisibility(View.VISIBLE);
        viewGroupFooter.setVisibility(View.VISIBLE);

        mTextSaveas.setVisibility(View.VISIBLE);
        mTextSaveas.setText(getArguments().getString(FileChooserActivity.EXTRA_DEFAULT_FILENAME));
        mTextSaveas.setOnEditorActionListener(new TextView.OnEditorActionListener() {

            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if (actionId == EditorInfo.IME_ACTION_DONE) {
                    UI.showSoftKeyboard(v, false);
                    mBtnOk.performClick();
                    return true;
                }
                return false;
            }// onEditorAction()
        });
        mTextSaveas.addTextChangedListener(new TextWatcher() {

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                /*
                 * Do nothing.
                 */
            }// onTextChanged()

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
                /*
                 * Do nothing.
                 */
            }// beforeTextChanged()

            @Override
            public void afterTextChanged(Editable s) {
                /*
                 * If the user taps a file, the tag is set to that file's
                 * URI. But if the user types the file name, we remove the
                 * tag.
                 */
                mTextSaveas.setTag(null);
            }// afterTextChanged()
        });

        mBtnOk.setVisibility(View.VISIBLE);
        mBtnOk.setOnClickListener(mBtnOk_SaveDialog_OnClickListener);
        mBtnOk.setBackgroundResource(
                UI.resolveAttribute(getActivity(), R.attr.anhuu_f5be488d_selector_button_ok_saveas));

        int size = getResources().getDimensionPixelSize(R.dimen.anhuu_f5be488d_button_ok_saveas_size);
        LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) mBtnOk.getLayoutParams();
        lp.width = size;
        lp.height = size;
        mBtnOk.setLayoutParams(lp);
    } // this is in save mode
    else {
        if (mIsMultiSelection) {
            viewGroupFooterContainer.setVisibility(View.VISIBLE);
            viewGroupFooter.setVisibility(View.VISIBLE);

            ViewGroup.LayoutParams lp = viewGroupFooter.getLayoutParams();
            lp.width = ViewGroup.LayoutParams.WRAP_CONTENT;
            viewGroupFooter.setLayoutParams(lp);

            mBtnOk.setMinWidth(
                    getResources().getDimensionPixelSize(R.dimen.anhuu_f5be488d_single_button_min_width));
            mBtnOk.setText(android.R.string.ok);
            mBtnOk.setVisibility(View.VISIBLE);
            mBtnOk.setOnClickListener(mBtnOk_OpenDialog_OnClickListener);
        }
    } // this is in open mode
}