Android GridLayout - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android GridLayout class.

This code example shows how to use the following methods:setLayoutDirection, addView, setAlignmentMode, setRowOrderPreserved, setUseDefaultMargins
        super.onViewCreated(view, savedInstanceState);
        currentView.addView(create(currentView.getContext()));
    } 
 
    public static View create(Context context) {
        GridLayout layout = new GridLayout(context);
        layout.setUseDefaultMargins(true);
        layout.setAlignmentMode(ALIGN_BOUNDS);
        layout.setRowOrderPreserved(false);
        layout.setLayoutDirection(View.LAYOUT_DIRECTION_RTL);
 
        Spec row1 = spec(0);
        Spec row2 = spec(1);
        Spec row3 = spec(2, BASELINE);
        Spec row4 = spec(3, BASELINE);
        Spec row5 = spec(2, 3, FILL); // allow the last two rows to overlap the middle two
        Spec row6 = spec(5);
        Spec row7 = spec(6);
 
        Spec col1a = spec(0, 4, CENTER);

8
CodeRank
This code example shows how to use the following methods:setLayoutDirection, addView, setAlignmentMode, setRowOrderPreserved, setUseDefaultMargins
        super.onViewCreated(view, savedInstanceState);
        currentView.addView(create(currentView.getContext()));
    } 
 
    public static View create(Context context) {
        GridLayout layout = new GridLayout(context);
        layout.setUseDefaultMargins(true);
        layout.setAlignmentMode(ALIGN_BOUNDS);
        layout.setRowOrderPreserved(false);
        layout.setLayoutDirection(View.LAYOUT_DIRECTION_LTR);
 
        Spec row1 = spec(0);
        Spec row2 = spec(1);
        Spec row3 = spec(2, BASELINE);
        Spec row4 = spec(3, BASELINE);
        Spec row5 = spec(2, 3, FILL); // allow the last two rows to overlap the middle two
        Spec row6 = spec(5);
        Spec row7 = spec(6);
 
        Spec col1a = spec(0, 4, CENTER);

8
CodeRank
This code example shows how to use the following methods:addView, getChildCount
This code example shows how to use the following methods:setLayoutDirection, addView, setAlignmentMode, setRowOrderPreserved, setUseDefaultMargins
        super.onViewCreated(view, savedInstanceState);
        currentView.addView(create(currentView.getContext()));
    } 
 
    public static View create(Context context) {
        GridLayout layout = new GridLayout(context);
        layout.setUseDefaultMargins(true);
        layout.setAlignmentMode(ALIGN_BOUNDS);
        layout.setRowOrderPreserved(false);
        layout.setLayoutDirection(View.LAYOUT_DIRECTION_RTL);
 
        Spec row1 = spec(0);
        Spec row2 = spec(1);
        Spec row3 = spec(2, BASELINE);
        Spec row4 = spec(3, BASELINE);
        Spec row5 = spec(2, 3, FILL); // allow the last two rows to overlap the middle two
        Spec row6 = spec(5);
        Spec row7 = spec(6);
 
        Spec col1a = spec(0, 4, CENTER);

6
CodeRank
This code example shows how to use the following methods:setLayoutDirection, addView, setAlignmentMode, setRowOrderPreserved, setUseDefaultMargins
        super.onViewCreated(view, savedInstanceState);
        currentView.addView(create(currentView.getContext()));
    } 
 
    public static View create(Context context) {
        GridLayout layout = new GridLayout(context);
        layout.setUseDefaultMargins(true);
        layout.setAlignmentMode(ALIGN_BOUNDS);
        layout.setRowOrderPreserved(false);
        layout.setLayoutDirection(View.LAYOUT_DIRECTION_LTR);
 
        Spec row1 = spec(0);
        Spec row2 = spec(1);
        Spec row3 = spec(2, BASELINE);
        Spec row4 = spec(3, BASELINE);
        Spec row5 = spec(2, 3, FILL); // allow the last two rows to overlap the middle two
        Spec row6 = spec(5);
        Spec row7 = spec(6);
 
        Spec col1a = spec(0, 4, CENTER);

6
CodeRank
This code example shows how to use the following methods:
import android.widget.GridLayout; 
 
public class Activity1 extends Activity {
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(new GridLayout(getBaseContext()));
    } 
} 
6
CodeRank
This code example shows how to use the following methods:addView, setColumnCount, setRowCount
5
CodeRank
This code example shows how to use the following methods:addView, setColumnCount, setRowCount, GridLayout.addView
5
CodeRank
This code example shows how to use the following methods:clearAnimation, setLayoutAnimation, startLayoutAnimation
This code example shows how to use the following methods:removeView
            public void onClick(View v) {
                Button newButton = new Button(LayoutAnimationsByDefault.this);
                newButton.setText(String.valueOf(numButtons++));
                newButton.setOnClickListener(new View.OnClickListener() {
                    public void onClick(View v) {
                        gridContainer.removeView(v);
                    } 
                }); 
                gridContainer.addView(newButton, Math.min(1, gridContainer.getChildCount()));
            } 
        }); 
    } 
 
} 
5
CodeRank

Related Android GridLayout Questions & Answers:

See Code Examples for Android GridLayout Methods: