Skip to content

Instantly share code, notes, and snippets.

View RamiJ3mli's full-sized avatar

Rami Jemli RamiJ3mli

View GitHub Profile
ConstraintSet c = new ConstraintSet();
c.clone(constraintLayout);
c.createHorizontalChain(ConstraintSet.PARENT_ID, ConstraintSet.LEFT, ConstraintSet.PARENT_ID, ConstraintSet.RIGHT, new int[]{R.id.button1, R.id.button2, R.id.button3}, null, ConstraintSet.CHAIN_SPREAD);
c.applyTo(constraintLayout);
@RamiJ3mli
RamiJ3mli / constraintset_chains.csv
Created August 19, 2018 16:57
ConstraintSet's list of methods related to chains
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 7.
ConstraintSet method, Explanation
"createHorizontalChain(int leftId, int leftSide, int rightId, int rightSide, int[] chainIds, float[] weights, int style)", "Creates a horizontal chain attached to the leftSide of leftId, and the rightSide of rightId. "
"createHorizontalChainRtl(int leftId, int leftSide, int rightId, int rightSide, int[] chainIds, float[] weights, int style)", "Creates a horizontal chain attached to the leftSide of leftId, and the rightSide of rightId with RTL support."
"createVerticalChain(int topId, int topSide, int bottomId, int bottomSide, int[] chainIds, float[] weights, int style)", "Creates a vertical chain attached to the topSide of topId, and the bottomSide of bottomId. "
"setHorizontalChainStyle(int viewId, int chainStyle)", "Applies a chain style on a horizontal chain's head view."
"setVerticalChainStyle(int viewId, int chainStyle)", "Applies a chain style on a vertical chain's head view."
"addToHorizontalChain(int viewId, int leftId, int rightId)", "Adds a view to a horizontal ch
@RamiJ3mli
RamiJ3mli / constraintset_views_manipulation.csv
Last active August 19, 2018 09:47
ConstraintSet's list of methods related to views manipulation
ConstraintSet method Explanation
setVisibility(int viewId, int visibility)
setAlpha(int viewId, float alpha)
setRotation(int viewId, float rotation)
setRotationX(int viewId, float rotationX)
setRotationY(int viewId, float rotationY)
setScaleX(int viewId, float scaleX)
setScaleY(int viewId, float scaleY)
setTransformPivot(int viewId, float transformPivotX, float transformPivotY)
@RamiJ3mli
RamiJ3mli / constraintset_dimensions.csv
Created August 18, 2018 17:16
ConstraintSet's list of methods related to dimensions
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 6.
XML, ConstraintSet method, Explanation
layout_height, "constrainHeight(int viewId, int height)","This method sets a view's height. the height can be fixed(exrpressed in dp), wrap content(ConstraintSet.WRAP_CONTENT), or match constraint(ConstraintSet.MATCH_CONSTRAINT)."
layout_width, "constrainWidth(int viewId, int width)","This method sets a view's width. the width can be fixed(exrpressed in dp), wrap content(ConstraintSet.WRAP_CONTENT), or match constraint(ConstraintSet.MATCH_CONSTRAINT)."
layout_constrainedHeight, "constrainDefaultHeight(int viewId, int height)","This method enforces the constrained height's behavior.the height param can be ConstraintSet.MATCH_CONSTRAINT_SPREAD (default), or ConstraintSet.MATCH_CONSTRAINT_WRAP."
layout_constrainedWidth, "constrainDefaultWidth(int viewId, int width)","This method enforces the constrained width's behavior.the width param can be ConstraintSet.MATCH_CONSTRAINT_SPREAD (default), or ConstraintSet.MATCH_CONSTRAINT_WRAP."
layout_constraintHeight_max, "constrainM
@RamiJ3mli
RamiJ3mli / constraintset_centering.csv
Last active August 18, 2018 16:03
ConstraintSet centering methods
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 5.
ConstraintSet method, Explanation
"center(int sourceViewId, int firstViewID, int firstViewSide, int firstViewMargin, int secondViewId, int secondViewSide, int secondViewMargin, float bias)","This method centers a view between two others with the possibility to set a margin and a bias at the same time."
"centerHorizontally (int sourceViewId, int leftViewId, int leftViewSide, int leftViewMargin, int rightViewId, int rightViewSide, int rightViewMargin, float bias)","This method centers a view between two others HORIZONTALLY with the possibility to set a margin and a bias at the same time."
"centerHorizontally (int sourceViewId, int targetViewId)","This method centers a view between the left and right sides of another view."
"centerHorizontallyRtl (int sourceViewId, int startViewId,int startViewSide,int startViewMargin,int endViewId,int endViewSide,int endViewMargin,float bias)","This method centers a view between two others HORIZONTALLY with the possibility to set a margin and a bias at the same time, and with
@RamiJ3mli
RamiJ3mli / constraintset_relative_positioning.csv
Last active August 18, 2018 16:34
ConstraintSet's list of methods
XML ConstraintSet method
layout_constraint[SourceSide]_to[TargetSide]Of="[Target Id OR parent]" c.connect(int sourceViewId, int sourceSide, int targetViewId, int targetSide);
layout_constraintTop_toTopOf="target id" c.connect(R.id.source_view_id, ConstraintSet.TOP, R.id.target_view_id, ConstraintSet.TOP);
layout_constraintTop_toTopOf="parent" c.connect(R.id.source_view_id, ConstraintSet.TOP, ConstraintSet.PARENT_ID, ConstraintSet.TOP);
layout_constraintBottom_toBottomOf="target id" c.connect(R.id.source_view_id, ConstraintSet.BOTTOM, R.id.target_view_id, ConstraintSet.BOTTOM);
layout_constraintBottom_toBottomOf="parent" c.connect(R.id.source_view_id, ConstraintSet.BOTTOM, ConstraintSet.PARENT_ID, ConstraintSet.BOTTOM);
layout_constraintLeft_toLeftOf="target id" c.connect(R.id.source_view_id, ConstraintSet.LEFT, R.id.target_view_id, ConstraintSet.LEFT);
@RamiJ3mli
RamiJ3mli / constraintlayout_barrier.xml
Created August 15, 2018 19:25
ConstraintLayout's Barrier feature
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/first_line"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cause I'm T.N.T. I'm dynamite"
@RamiJ3mli
RamiJ3mli / constraintlayout_constraints.xml
Created August 15, 2018 18:40
ConstraintLayout's relative positioning constraints
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/avatar"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginTop="16dp"
@RamiJ3mli
RamiJ3mli / constraintlayout_aspect_ratio.xml
Created August 15, 2018 13:05
ConstraintLayout's aspect ratio
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.constraint.Guideline
android:id="@+id/left_ruler"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
@RamiJ3mli
RamiJ3mli / constraintlayout_guideline.xml
Last active August 13, 2018 17:08
ConstraintLayout's guideline usage
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.constraint.Guideline
android:id="@+id/keyline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"