Example usage for android.widget LinearLayout setLayoutParams

List of usage examples for android.widget LinearLayout setLayoutParams

Introduction

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

Prototype

public void setLayoutParams(ViewGroup.LayoutParams params) 

Source Link

Document

Set the layout parameters associated with this view.

Usage

From source file:com.garage.payless.fragment.FragmentList.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View rootView = inflater.inflate(R.layout.list_fragment, container, false);

    DelayAutoCompleteTextView bookTitle = (DelayAutoCompleteTextView) rootView.findViewById(R.id.book_title);
    bookTitle.setThreshold(4);/*from   ww  w.  j  a v  a2s.c  o  m*/
    bookTitle.setAdapter(new GoodAutoCompleteAdapter(getActivity().getApplicationContext()));
    bookTitle.setLoadingIndicator((ProgressBar) rootView.findViewById(R.id.progress_bar));
    bookTitle.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
            LinearLayout basketList = (LinearLayout) rootView.findViewById(R.id.basket);
            LinearLayout row = new LinearLayout(getActivity().getApplicationContext());
            row.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
                    LinearLayout.LayoutParams.WRAP_CONTENT));
            row.setOrientation(LinearLayout.HORIZONTAL);
            TextView valueTV = new TextView(getActivity().getApplicationContext());
            valueTV.setText((String) adapterView.getItemAtPosition(position));
            valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
                    LinearLayout.LayoutParams.WRAP_CONTENT));
            row.addView(valueTV);
            ImageButton cancel = new ImageButton(getActivity().getApplicationContext());
            cancel.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                    LinearLayout.LayoutParams.WRAP_CONTENT));
            cancel.setImageDrawable(Drawable.createFromPath("@android:drawable/ic_menu_close_clear_cancel"));
            row.addView(cancel);
            basketList.addView(row);
        }
    });
    rootView.findViewById(R.id.create_btn).setOnClickListener(this);
    return rootView;
}

From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.MusicObj.java

public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) {
    JSONObject content = obj.getJson();/*from  w  w w.j  a va2s. c om*/
    LinearLayout container = new LinearLayout(context);
    container.setLayoutParams(CommonLayouts.FULL_WIDTH);
    container.setOrientation(LinearLayout.HORIZONTAL);
    container.setGravity(Gravity.CENTER);

    ImageView imageView = new ImageView(context);
    imageView.setImageResource(R.drawable.play);
    imageView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));

    TextView valueTV = new TextView(context);
    valueTV.setText(asText(content));
    valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));
    valueTV.setGravity(Gravity.BOTTOM | Gravity.LEFT);
    valueTV.setPadding(4, 0, 0, 0);

    container.addView(imageView);
    container.addView(valueTV);
    frame.addView(container);
}

From source file:ovh.ice.icecons.LicenseActivity.java

private void createLayout() {

    // main centered layout

    LinearLayout.LayoutParams smallLayoutParams = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1f);
    float scale = IceScreenUtils.densityScale(getApplicationContext());
    int padding = Math.round(64 * scale);

    LinearLayout frameLayout = new LinearLayout(this);
    frameLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.MATCH_PARENT));
    frameLayout.setBackgroundColor(0xffffffff);
    frameLayout.setGravity(Gravity.CENTER);
    setContentView(frameLayout);/*from w  w w .  j  a  v  a  2 s  . c  o  m*/

    LinearLayout baseLayout = new LinearLayout(this);
    baseLayout.setOrientation(LinearLayout.VERTICAL);
    baseLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.MATCH_PARENT));
    baseLayout.setGravity(Gravity.LEFT);
    frameLayout.addView(baseLayout);

    // gpl button

    LinearLayout sourceLayout = new LinearLayout(this);
    sourceLayout.setOrientation(LinearLayout.HORIZONTAL);
    sourceLayout.setLayoutParams(smallLayoutParams);
    sourceLayout.setGravity(Gravity.CENTER);
    baseLayout.addView(sourceLayout);

    LinearLayout sourceClickLayout = new LinearLayout(this);
    sourceClickLayout.setOrientation(LinearLayout.HORIZONTAL);
    sourceClickLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));
    sourceClickLayout.setGravity(Gravity.CENTER);
    sourceLayout.addView(sourceClickLayout);
    sourceClickLayout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            gplLink(v);
        }
    });

    TextView sourceText = new TextView(this);
    sourceText.setText("This program's source code is avaiable under the GNU General Public License v3.");
    sourceText.setTextSize(24);
    sourceText.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.colorPrimaryDark));
    sourceText.setPadding(padding, padding, padding, padding);
    sourceClickLayout.addView(sourceText);

    // cc button

    LinearLayout imgLayout = new LinearLayout(this);
    imgLayout.setOrientation(LinearLayout.HORIZONTAL);
    imgLayout.setLayoutParams(smallLayoutParams);
    imgLayout.setGravity(Gravity.CENTER);
    imgLayout.setBackgroundColor(0xff000000);
    baseLayout.addView(imgLayout);

    LinearLayout imgClickLayout = new LinearLayout(this);
    imgClickLayout.setOrientation(LinearLayout.HORIZONTAL);
    imgClickLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));
    imgClickLayout.setGravity(Gravity.CENTER);
    imgLayout.addView(imgClickLayout);
    imgClickLayout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ccLink(v);
        }
    });

    TextView aboutText = new TextView(this);
    aboutText.setText(
            "All the images included in this program are avaiable under the Creative Commons Attribution Share Alike 4.0 license.");
    aboutText.setTextSize(24);
    aboutText.setTextColor(0xffffffff);
    aboutText.setPadding(padding, padding, padding, padding);
    imgClickLayout.addView(aboutText);

}

From source file:com.android.inputmethod.keyboard.emoji.EmojiLayoutParams.java

public void setActionBarProperties(final LinearLayout ll) {
    final LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) ll.getLayoutParams();
    lp.height = getActionBarHeight();/*ww w  . j a v a2  s. c  o m*/
    ll.setLayoutParams(lp);
}

From source file:com.android.inputmethod.keyboard.EmojiLayoutParams.java

public void setCategoryPageIdViewProperties(LinearLayout ll) {
    final LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) ll.getLayoutParams();
    lp.height = mEmojiCategoryPageIdViewHeight;
    ll.setLayoutParams(lp);
}

From source file:com.android.inputmethod.keyboard.EmojiLayoutParams.java

public void setActionBarProperties(LinearLayout ll) {
    final LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) ll.getLayoutParams();
    lp.height = mEmojiActionBarHeight - mBottomPadding;
    ll.setLayoutParams(lp);
}

From source file:de.gebatzens.ggvertretungsplan.fragment.ExamFragment.java

@Override
public void createView(LayoutInflater inflater, ViewGroup view) {
    ScrollView sv = new ScrollView(getActivity());
    sv.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    sv.setTag("exam_scroll");
    ((LinearLayout) view.findViewById(R.id.exam_content)).addView(sv);
    LinearLayout l = new LinearLayout(getActivity());
    l.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    l.setOrientation(LinearLayout.VERTICAL);
    int p = toPixels(6);
    l.setPadding(p, p, p, p);//from w w  w.j a v a2 s  .  c o m
    sv.addView(l);
    createTextView(getResources().getString(R.string.my_exams), toPixels(12), inflater, l);
    for (Exams.ExamItem item : GGApp.GG_APP.exams) {
        if (GGApp.GG_APP.filters.mainFilter.matches(item)) {
            CardView cv = createCardItem(item, inflater);
            if (cv != null) {
                l.addView(cv);
            }
        }

    }
    createTextView(getResources().getString(R.string.all_exams), toPixels(12), inflater, l);
    for (Exams.ExamItem item : GGApp.GG_APP.exams) {
        CardView cv = createCardItem(item, inflater);
        if (cv != null) {
            l.addView(cv);
        }
    }
    cardColorIndex = 0;
}

From source file:com.activiti.android.app.fragments.account.WelcomeFragment.java

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    setRetainInstance(false);/*from ww w.ja  va  2  s. c o  m*/

    if (getRootView() != null) {
        return getRootView();
    }

    setRootView(inflater.inflate(R.layout.fr_welcome, container, false));

    // Instantiate a ViewPager and a PagerAdapter.
    Bundle extras = getArguments();
    if (extras != null && extras.containsKey(WelcomeActivity.EXTRA_ADD_ACCOUNT)) {
        hide(R.id.welcome_title);
        hide(R.id.welcome_pager);
        hide(R.id.welcome_pager_indicator);
        LinearLayout layout = (LinearLayout) viewById(R.id.welcome_page_actions_container);
        layout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.MATCH_PARENT));
    } else if (getActivity().findViewById(R.id.double_panel) != null) {
        hide(R.id.welcome_title);
        hide(R.id.welcome_pager);
        hide(R.id.welcome_pager_indicator);
        LinearLayout layout = (LinearLayout) viewById(R.id.welcome_page_actions_container);
        layout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.MATCH_PARENT));
    } else {
        CircleIndicator defaultIndicator = (CircleIndicator) viewById(R.id.welcome_pager_indicator);
        mPager = (ViewPager) viewById(R.id.welcome_pager);
        mPagerAdapter = new ScreenSlidePagerAdapter(getFragmentManager());
        mPager.setAdapter(mPagerAdapter);
        defaultIndicator.setViewPager(mPager);
    }

    return getRootView();
}

From source file:co.ldln.android.ObjectReadFragment.java

@Override
public void onReadSchemaResult(Schema schema) {
    mSchema = schema;/* w w  w  .j  a  v a 2s.c  o m*/
    HashMap<String, String> keyValueMap = mSyncableObject.getKeyValueMap();
    for (SchemaField schemaField : mSchema.getFields(mActivity)) {
        String label = schemaField.getLabel();
        String value = keyValueMap.get(label);
        String type = schemaField.getType();

        // Create a linear layout to hold the field
        LinearLayout ll = new LinearLayout(mActivity);
        LayoutParams llParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        ll.setLayoutParams(llParams);
        ll.setOrientation(LinearLayout.HORIZONTAL);

        // TODO: different UI for different field types

        // Default to TextView
        TextView labelTv = new TextView(mActivity);
        LayoutParams labelTvParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        labelTv.setLayoutParams(labelTvParams);
        labelTv.setText(label);
        labelTv.setPadding(0, 0, 20, 0);
        labelTv.setTypeface(Typeface.DEFAULT_BOLD);
        ll.addView(labelTv);

        TextView valueTv = new TextView(mActivity);
        LayoutParams valueTvParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        valueTv.setLayoutParams(valueTvParams);
        valueTv.setText(value);
        ll.addView(valueTv);

        mFormHolder.addView(ll);
    }
}

From source file:com.example.angelina.travelapp.map.MapActivity.java

/**
 * Display the specific directions for the segment of the route
 * the user has clicked on.//from www .  j ava  2  s  . c o  m
 * @param position An integer representing the index in the
 *                 list of segment directions.
 */
public final void showRouteDetail(final int position) {
    // Hide the list of directions
    final LinearLayout layout = (LinearLayout) findViewById(R.id.route_directions_container);
    layout.setLayoutParams(new CoordinatorLayout.LayoutParams(0, 0));
    layout.requestLayout();

    // Restore the map, removing any route segment detail
    final MapFragment mapFragment = restoreMapAndRemoveRouteDetail();
    // Add specific route segment detail
    mapFragment.showRouteDetail(position);
}