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.example.android.animationsdemo.BoardFragment.java

public void createCol() {
    int colNo = board.getColNo();
    Log.i("colNo", "colNo=" + colNo);
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);/*w  w  w. j a v a 2 s . c  o  m*/
    int width = size.x;
    int height = size.y;
    Log.i("conditions", "codition start=" + Math.max(0, start) + "\n check = "
            + Math.min(start + MAX_COL_DISPLAYED, board.getColNo()) + "in createCOl");
    for (int i = Math.max(0, start); i < Math.min(start + MAX_COL_DISPLAYED, board.getColNo()); i++) {
        LayoutInflater inflater = LayoutInflater.from(context);
        View columnView = inflater.inflate(R.layout.columns_layout, null, false);
        LinearLayout ll = (LinearLayout) columnView.findViewById(R.id.ll);
        ll.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.MATCH_PARENT, 1.0f / MAX_COL_DISPLAYED));
        TextView tv = (TextView) columnView.findViewById(R.id.tv);
        tv.setText(board.getColName(i));
        Button addCard = (Button) columnView.findViewById(R.id.addCard);
        LinearLayout cardContainerLayout = (LinearLayout) columnView.findViewById(R.id.cardContainer);
        cardContainerLayout.setTag("col" + board.getColName(i));
        cardContainerLayout.setId(position);
        cardContainerLayout.setMinimumHeight(height);
        cardContainerLayout.setMinimumWidth(width / MAX_COL_DISPLAYED);
        Log.i("Drag", "Calling drag constructor ");
        cardContainerLayout.setOnDragListener(new MyDragListener(rootViewGroup));
        Log.i("Drag", "Drag Constructor Called ");
        addCard.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                BoardFragment.this.addItem(view);
            }
        });
        //cardContainerLayout.setLayoutTransition(new LayoutTransition());

        rootViewGroup.addView(columnView);
    }
}

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

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup group, Bundle bundle) {
    LinearLayout l = new LinearLayout(getActivity());
    l.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    l.setOrientation(LinearLayout.VERTICAL);
    if (GGApp.GG_APP.getDataForFragment(type) != null)
        createRootView(inflater, l);/*from   www. ja  v  a  2 s . c  o  m*/
    return l;
}

From source file:com.farmerbb.taskbar.activity.DashboardActivity.java

@SuppressWarnings("deprecation")
@Override//from  w  w  w . j  a v  a  2 s.c o m
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    contextMenuFix = getIntent().hasExtra("context_menu_fix");

    // Detect outside touches, and finish the activity when one is detected
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
            WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
            WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH);

    DisplayManager dm = (DisplayManager) getSystemService(DISPLAY_SERVICE);
    Display display = dm.getDisplay(Display.DEFAULT_DISPLAY);

    setContentView(R.layout.incognito);

    LinearLayout layout = (LinearLayout) findViewById(R.id.incognitoLayout);
    layout.setLayoutParams(new FrameLayout.LayoutParams(display.getWidth(), display.getHeight()));

    LocalBroadcastManager.getInstance(this).registerReceiver(addWidgetReceiver,
            new IntentFilter("com.farmerbb.taskbar.ADD_WIDGET_REQUESTED"));
    LocalBroadcastManager.getInstance(this).registerReceiver(removeWidgetReceiver,
            new IntentFilter("com.farmerbb.taskbar.REMOVE_WIDGET_REQUESTED"));
    LocalBroadcastManager.getInstance(this).registerReceiver(finishReceiver,
            new IntentFilter("com.farmerbb.taskbar.DASHBOARD_DISAPPEARING"));

    if (!DashboardHelper.getInstance().isDashboardOpen())
        finish();
}

From source file:com.yanzhenjie.recyclerview.swipe.SwipeMenuView.java

public void createMenu(SwipeMenu swipeMenu, SwipeSwitch swipeSwitch,
        SwipeMenuItemClickListener swipeMenuItemClickListener,
        @SwipeMenuRecyclerView.DirectionMode int direction) {
    removeAllViews();/*from ww  w  .  j a  va  2 s .c o  m*/

    this.mSwipeSwitch = swipeSwitch;
    this.mItemClickListener = swipeMenuItemClickListener;
    this.mDirection = direction;

    List<SwipeMenuItem> items = swipeMenu.getMenuItems();
    for (int i = 0; i < items.size(); i++) {
        SwipeMenuItem item = items.get(i);

        LayoutParams params = new LayoutParams(item.getWidth(), item.getHeight());
        params.weight = item.getWeight();
        LinearLayout parent = new LinearLayout(getContext());
        parent.setId(i);
        parent.setGravity(Gravity.CENTER);
        parent.setOrientation(VERTICAL);
        parent.setLayoutParams(params);
        ViewCompat.setBackground(parent, item.getBackground());
        parent.setOnClickListener(this);
        addView(parent);

        SwipeMenuBridge menuBridge = new SwipeMenuBridge(mDirection, i, mSwipeSwitch, parent);
        parent.setTag(menuBridge);

        if (item.getImage() != null) {
            ImageView iv = createIcon(item);
            menuBridge.mImageView = iv;
            parent.addView(iv);
        }

        if (!TextUtils.isEmpty(item.getText())) {
            TextView tv = createTitle(item);
            menuBridge.mTextView = tv;
            parent.addView(tv);
        }
    }
}

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

public View createLoadingView() {
    LinearLayout l = new LinearLayout(getActivity());
    l.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    l.setGravity(Gravity.CENTER);//ww  w . j  a v a 2  s . c o  m

    ProgressBar pb = new ProgressBar(getActivity());
    pb.getIndeterminateDrawable().setColorFilter(GGApp.GG_APP.provider.getColor(), PorterDuff.Mode.SRC_IN);
    pb.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    pb.setVisibility(ProgressBar.VISIBLE);

    l.addView(pb);
    return l;
}

From source file:de.gebatzens.sia.fragment.RemoteDataFragment.java

public View createLoadingView() {
    ScrollView sv = new ScrollView(getActivity());
    sv.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    sv.setTag("gg_scroll");
    sv.setFillViewport(true);/*from  ww  w.  ja v  a2  s .c  o m*/
    LinearLayout l = new LinearLayout(getActivity());
    l.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    l.setGravity(Gravity.CENTER);

    ProgressBar pb = new ProgressBar(getActivity());
    pb.getIndeterminateDrawable().setColorFilter(SIAApp.SIA_APP.school.getAccentColor(),
            PorterDuff.Mode.SRC_IN);
    pb.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    pb.setVisibility(ProgressBar.VISIBLE);

    l.addView(pb);
    sv.addView(l);
    return sv;
}

From source file:de.gebatzens.sia.fragment.RemoteDataFragment.java

public void createNoEntriesCard(ViewGroup parent, LayoutInflater inflater) {
    LinearLayout wrapper = new LinearLayout(parent.getContext());
    wrapper.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    setOrientationPadding(wrapper);/*w ww.  j  av  a  2s .c  om*/

    CardView cv = (CardView) inflater.inflate(R.layout.basic_cardview, wrapper, false);
    createPrimaryTextView(getResources().getString(R.string.no_entries), 20, inflater, cv);
    wrapper.addView(cv);
    parent.addView(wrapper);
}

From source file:mobisocial.musubi.objects.PictureObj.java

@Override
public View createView(Context context, ViewGroup parent) {
    LinearLayout frame = new LinearLayout(context);
    frame.setLayoutParams(CommonLayouts.FULL_WIDTH);
    frame.setOrientation(LinearLayout.VERTICAL);

    ImageView imageView = new ImageView(context);
    imageView.setBackgroundResource(android.R.drawable.picture_frame);
    imageView.setPadding(6, 4, 8, 9);//w w  w  .j  a  v a  2s  . co  m
    frame.addView(imageView);

    TextView textView = new TextView(context);
    frame.addView(textView);

    return frame;
}

From source file:freed.cam.ui.themesample.cameraui.HorizontalValuesFragment.java

private LinearLayout getNewLayout() {
    LinearLayout linearLayout = new LinearLayout(getContext());
    linearLayout.setOrientation(LinearLayout.HORIZONTAL);

    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    linearLayout.setLayoutParams(params);
    linearLayout.setGravity(Gravity.CENTER_HORIZONTAL);
    valuesHolder.addView(linearLayout);/*w  w w. j  ava 2  s .  c  o  m*/
    return linearLayout;
}

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

@Override
public void onReadSchemaResult(final Schema schema) {
    mTextFields = new ArrayList<EditText>();

    // Create the form based on the schema fields
    List<SchemaField> fieldList = new ArrayList<SchemaField>();
    fieldList.addAll(schema.getFields(mActivity));
    Collections.sort(fieldList);//from w  w  w.ja va  2  s  . co m
    for (SchemaField field : fieldList) {
        String type = field.getType();
        String label = field.getLabel();

        // 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 EditText
        EditText et = new EditText(mActivity);
        LayoutParams etParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        et.setLayoutParams(etParams);
        et.setHint(label);
        if (type.equals("map_location"))
            et.setText(mMapLocation);
        ll.addView(et);
        mTextFields.add(et);

        mFormHolder.addView(ll);
    }

    // Add submit button
    Button b = new Button(mActivity);
    LayoutParams bParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    b.setText("Save");
    b.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            try {
                String kvPairs = "";
                JSONObject kvPairsJsonObject = new JSONObject();
                for (EditText et : mTextFields) {
                    String key = et.getHint().toString();
                    String value = et.getText().toString();
                    kvPairsJsonObject.put(key, value);
                }
                kvPairs = kvPairsJsonObject.toString();

                LDLN.saveSyncableObject(mActivity, ObjectCreateFragment.this, schema.getKey(), kvPairs);
            } catch (JSONException e) {
                e.printStackTrace();
                onSaveSyncableObjectResult(false);
            }
        }
    });
    mFormHolder.addView(b);

    Toast.makeText(mActivity,
            "This is a form that's dynamically generated from a syncable object schema. It will soon have handling for dynamic form elements (photo, latlon picker, etc).",
            Toast.LENGTH_LONG).show();
}