Example usage for android.view View setLayoutParams

List of usage examples for android.view View setLayoutParams

Introduction

In this page you can find the example usage for android.view View setLayoutParams.

Prototype

public void setLayoutParams(ViewGroup.LayoutParams params) 

Source Link

Document

Set the layout parameters associated with this view.

Usage

From source file:com.odoo.base.login_signup.SyncWizard.java

private void generateLayout() {

    LinearLayout layout = (LinearLayout) rootView.findViewById(R.id.layoutLoginConfig);
    SyncWizardValues syncValues = new SyncWizardValues();
    List<SyncValue> syncValuesList = syncValues.syncValues();
    if (syncValuesList.size() == 0) {
        getActivity().finish();//from w ww  . jav a 2  s .c  o m
        getActivity().startActivity(getActivity().getIntent());
    }
    checkbox = new CheckBox[syncValuesList.size()];
    rdoGroups = new RadioGroup[syncValuesList.size()];
    TextView[] txvTitles = new TextView[syncValuesList.size()];
    int i = 0;
    int id = 1;
    Typeface tf_light = Typeface.create("sans-serif-light", 0);
    Typeface tf_bold = Typeface.create("sans-serif-condensed", 0);
    for (SyncValue value : syncValuesList) {
        if (!value.getIsGroup()) {
            if (value.getType() == SyncValue.Type.CHECKBOX) {
                checkbox[i] = new CheckBox(scope.context());
                checkbox[i].setId(id);
                checkbox[i].setText(value.getTitle());
                checkbox[i].setTypeface(tf_light);
                layout.addView(checkbox[i]);
            } else {
                rdoGroups[i] = new RadioGroup(scope.context());
                rdoGroups[i].setId(i + 50);
                RadioButton[] rdoButtons = new RadioButton[value.getRadioGroups().size()];
                int mId = 1;
                int j = 0;
                for (SyncValue rdoVal : value.getRadioGroups()) {
                    rdoButtons[j] = new RadioButton(scope.context());
                    rdoButtons[j].setId(mId);
                    rdoButtons[j].setText(rdoVal.getTitle());
                    rdoButtons[j].setTypeface(tf_light);
                    rdoGroups[i].addView(rdoButtons[j]);
                    mId++;
                    j++;
                }
                layout.addView(rdoGroups[i]);
            }
            authorities.put(id + "", value.getAuthority());
            i++;
            id++;
        } else {
            txvTitles[i] = new TextView(scope.context());
            txvTitles[i].setId(id);
            txvTitles[i].setText(value.getTitle());
            txvTitles[i].setAllCaps(true);
            txvTitles[i].setPadding(0, 5, 0, 3);
            txvTitles[i].setTypeface(tf_bold);
            layout.addView(txvTitles[i]);
            View lineView = new View(scope.context());
            lineView.setBackgroundColor(Color.parseColor("#BEBEBE"));
            lineView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, 1));
            layout.addView(lineView);
        }
    }
}

From source file:com.astuetz.viewpager.extensions.FixedTabsView.java

/**
 * Initialize and add all tabs to the layout
 */// w  w  w. j  a v a2 s  . c om
private void initTabs() {

    removeAllViews();
    mTabs.clear();

    if (mAdapter == null)
        return;

    for (int i = 0; i < mPager.getAdapter().getCount(); i++) {

        final int index = i;

        View tab = mAdapter.getView(i);
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1.0f);
        tab.setLayoutParams(params);
        this.addView(tab);

        mTabs.add(tab);

        if (i != mPager.getAdapter().getCount() - 1) {
            this.addView(getSeparator());
        }

        tab.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                mPager.setCurrentItem(index);
            }
        });

    }

    selectTab(mPager.getCurrentItem());
}

From source file:com.social.solution.activity.UserProfile.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_parallaxtoolbarlistviewa);

    //setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
    activityReference = this;

    mRequestQueue = Volley.newRequestQueue(this);
    imageLoader = new com.mopub.volley.toolbox.ImageLoader(mRequestQueue,
            new com.mopub.volley.toolbox.ImageLoader.ImageCache() {
                private final LruCache<String, Bitmap> mCache = new LruCache<String, Bitmap>(10);

                public void putBitmap(String url, Bitmap bitmap) {
                    mCache.put(url, bitmap);
                }/*from w  ww  .jav a2  s .com*/

                public Bitmap getBitmap(String url) {
                    return mCache.get(url);
                }
            });

    picture = (SquareImageView) findViewById(R.id.userimage);
    new LoadProfileImage().execute("0", "1");

    myTextView = findViewById(R.id.myflexibleview);
    //        mToolbarView = findViewById(R.id.toolbar);
    //        mToolbarView.setBackgroundColor(ScrollUtils.getColorWithAlpha(0, getResources().getColor(R.color.primary)));

    mParallaxImageHeight = getResources().getDimensionPixelSize(R.dimen.parallax_image_height);

    mListView = (ObservableListView) findViewById(R.id.list);
    mListView.setScrollViewCallbacks(this);
    // Set padding view for ListView. This is the flexible space.
    View paddingView = new View(this);
    AbsListView.LayoutParams lp = new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT,
            mParallaxImageHeight);
    paddingView.setLayoutParams(lp);

    // This is required to disable header's list selector effect
    paddingView.setClickable(true);

    mListView.addHeaderView(paddingView);
    setDummyData(mListView);

    // mListBackgroundView makes ListView's background except header view.
    mListBackgroundView = findViewById(R.id.list_background);
}

From source file:com.gosuncn.core.ui.widget.ToolbarExtend.java

protected void changeTitleGravity() {
    for (int i = 0; i < getChildCount(); i++) {
        View view = getChildAt(i);
        if (view != null && view instanceof TextView) {
            LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            lp.gravity = titleGravity;//from   w ww.  j av a2  s  .c  o m
            view.setLayoutParams(lp);
        }
    }
}

From source file:com.igs.qhrzlc.utils.view.astuetz.viewpager.extensions.FixedTabsView.java

/**
 * Creates and returns a new Separator View
 * /*from www. java2 s.c  o  m*/
 * @return
 */
private View getSeparator() {
    View v = new View(mContext);

    LayoutParams params = new LayoutParams(1, LayoutParams.FILL_PARENT);
    params.setMargins(0, mDividerMarginTop, 0, mDividerMarginBottom);
    v.setLayoutParams(params);

    if (mDividerDrawable != null)
        v.setBackgroundDrawable(mDividerDrawable);
    else
        v.setBackgroundColor(mDividerColor);

    return v;
}

From source file:com.borqs.qiupu.fragment.FixedTabsView.java

/**
 * Initialize and add all tabs to the layout
 *///from w  w w.  jav  a 2  s . c o  m
private void initTabs() {

    removeAllViews();
    mTabs.clear();

    if (mAdapter == null)
        return;

    for (int i = 0; i < mPager.getAdapter().getCount(); i++) {

        final int index = i;

        View tab = mAdapter.getView(i);
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);
        tab.setLayoutParams(params);
        this.addView(tab);

        mTabs.add(tab);

        //TODO add separator
        //         if (i != mPager.getAdapter().getCount() - 1) {
        //            this.addView(getSeparator());
        //         }

        tab.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                mPager.setCurrentItem(index);
            }
        });

    }

    selectTab(mSelectTab);
}

From source file:com.prettygirl.avgallery.components.FixedTabsView.java

/**
 * Initialize and add all tabs to the layout
 *//*w  w  w.  jav  a  2s  .c  o  m*/
private void initTabs() {

    removeAllViews();
    mTabs.clear();

    if (mAdapter == null)
        return;

    for (int i = 0; i < mPager.getAdapter().getCount(); i++) {

        final int index = i;

        View tab = mAdapter.getView(i);
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);
        tab.setLayoutParams(params);
        this.addView(tab);

        mTabs.add(tab);

        if (i != mPager.getAdapter().getCount() - 1) {
            this.addView(getSeparator());
        }

        tab.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                mPager.setCurrentItem(index);
            }
        });

    }

    selectTab(mPager.getCurrentItem());
}

From source file:com.b44t.ui.Components.PagerSlidingTabStrip.java

private void updateTabStyles() {
    for (int i = 0; i < tabCount; i++) {
        View v = tabsContainer.getChildAt(i);
        v.setLayoutParams(defaultTabLayoutParams);
        if (shouldExpand) {
            v.setPadding(0, 0, 0, 0);/*from  w w  w.ja  va2  s  .c om*/
            v.setLayoutParams(new LinearLayout.LayoutParams(-1, -1, 1.0F));
        } else {
            v.setPadding(tabPadding, 0, tabPadding, 0);
        }
    }
}

From source file:com.astuetz.viewpager.extensions.FixedTabsView.java

/**
 * Creates and returns a new Separator View
 *
 * @return//w w w. j  a  v  a2s  .c o m
 */
private View getSeparator() {
    View v = new View(mContext);

    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(1, LayoutParams.FILL_PARENT);
    params.setMargins(0, mDividerMarginTop, 0, mDividerMarginBottom);
    v.setLayoutParams(params);

    if (mDividerDrawable != null)
        v.setBackgroundDrawable(mDividerDrawable);
    else
        v.setBackgroundColor(mDividerColor);

    return v;
}

From source file:com.laer.easycast.VideoPane.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View root = new View(getActivity());
    root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    root.setBackgroundColor(Color.WHITE);
    root = inflater.inflate(R.layout.imagepane, container, false);
    setHasOptionsMenu(true);/*  ww  w .  j ava 2 s .  c o  m*/
    myViewGroup = container;

    cursor = getActivity().getContentResolver().query(MediaStore.Video.Thumbnails.EXTERNAL_CONTENT_URI,

            projection, // Which columns to return

            null, // Return all rows

            null, MediaStore.Video.Thumbnails.VIDEO_ID);

    // Get the column index of the Thumbnails Image ID

    columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Video.Thumbnails._ID);

    GridView gridView = (GridView) root.findViewById(R.id.gridView1);

    gridView.setAdapter(new ImageAdapter(getActivity()));

    gridView.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
            String[] projection = { MediaStore.Video.Media.DATA };
            try {
                cursor = getActivity().getContentResolver().query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI,

                        projection, // Which columns to return

                        null, // Return all rows

                        null,

                        null);
                columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATA);
            } catch (SQLiteException e) {

            }

            cursor.moveToPosition(position);

            // Get image filename
            String imagePath = cursor.getString(columnIndex);
            // Bitmap image = BitmapFactory.decodeFile(imagePath);

            Log.i("VideoPath=", imagePath);
            Log.d(TAG, "Video decoded");

            // videoRaw(image,NONE);

            // Use this path to do further processing, i.e. full screen
            // display
        }
    });

    return root;
}