Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LayoutParams from support libraries and custom views #69

Open
18 of 29 tasks
zserge opened this issue May 6, 2016 · 3 comments
Open
18 of 29 tasks

LayoutParams from support libraries and custom views #69

zserge opened this issue May 6, 2016 · 3 comments

Comments

@zserge
Copy link
Collaborator

zserge commented May 6, 2016

Layout params are not handled by generated DSL now. They are handled by hand-written BaseDSL in anvil base library. There are custom views that use their own layout params that BaseDSL knows nothing about. So far there is no way to set such layout params except for calling layoutParams method directly.

Here's a list of all ViewGroup.LayoutParams implementations:

  • AbsListView.LayoutParams - same as normal LayoutParams
  • AbsoluteLayout.LayoutParams - adds x and y to LayoutParams, but AbsoluteLayout is deprecated
  • ActionBar.LayoutParams - adds gravity to MarginLayoutParams, not via XML
  • ActionMenuView.LayoutParams - adds cellsUsed, expandable, extraPixels, isOverflowButton, preventEdgeOffset to MarginLayoutParams, not via XML
  • AppBarLayout.LayoutParams - same as LinearLayout.LayoutParams
  • BaseCardView.LayoutParams - adds viewType to FrameLayout.LayoutParams, not via XML
  • CollapsingToolbarLayout.LayoutParams - adds CollapseMode and parallax multiplier to FrameLayout.LayoutParams, not via XML
  • CoordinatorLayout.LayoutParams - adds anchorGravity, gravity and keyline to MarginLayoutParams
  • DrawerLayout.LayoutParams - adds gravity to MarginLayoutParams
  • FrameLayout.LayoutParams - adds gravity to MarginLayoutParams
  • Gallery.LayoutParams - same as normal LayoutParams
  • GridLayout.LayoutParams - adds row and column spec to MarginLayoutParams
  • GridLayoutManager.LayoutParams - same as MarginLayoutParams
  • LinearLayout.LayoutParams - adds weight and gravity to MarginLayoutParams
  • LinearLayoutCompat.LayoutParams - also adds weight and gravity to MarginLayoutParams, rarely used and not via XML
  • PercentFrameLayout.LayoutParams - same as FrameLayout.LayoutParams
  • PercentRelativeLayout.LayoutParams - same as RelativeLayout.LayoutParams
  • RadioGroup.LayoutParams - same as LinearLayout.LayoutParams
  • RecyclerView.LayoutParams - same as MarginLayoutParams
  • RelativeLayout.LayoutParams - adds rules to MarginLayoutParams
  • SlidingPaneLayout.LayoutParams - adds weight to MarginLayoutParams
  • StaggeredGridLayoutManager.LayoutParams - same as MarginLayoutParams
  • TableLayout.LayoutParams - same as LinearLayout.LayoutParams
  • TableRow.LayoutParams - adds column and span to LinearLayout.LayoutParams
  • Toolbar.LayoutParams - same as ActionBar.LayoutParams, not via XML
  • ViewGroup.LayoutParams (base) has width and height
  • ViewGroup.MarginLayoutParams - adds margin to base LayoutParams
  • ViewPager.LayoutParams - adds gravity and isDecor to base LayoutParams, not via XML
  • WindowManager.LayoutParams - adds lots of fields, but none of them exporeted via XML
@zserge
Copy link
Collaborator Author

zserge commented May 6, 2016

Also, here's a list of XML properties related to layout params:

  • layout_above
  • layout_alignBaseline
  • layout_alignBottom
  • layout_alignEnd
  • layout_alignLeft
  • layout_alignParentBottom
  • layout_alignParentEnd
  • layout_alignParentLeft
  • layout_alignParentRight
  • layout_alignParentStart
  • layout_alignParentTop
  • layout_alignRight
  • layout_alignStart
  • layout_alignTop
  • layout_alignWithParentIfMissing
  • layout_below
  • layout_centerHorizontal
  • layout_centerInParent
  • layout_centerVertical
  • layout_gravity - should be also supported in v4/v7 libraries
  • layout_height
  • layout_margin
  • layout_marginBottom
  • layout_marginEnd
  • layout_marginLeft
  • layout_marginRight
  • layout_marginStart
  • layout_marginTop
  • layout_scale - what view uses this XML attr?
  • layout_span - specific to TableRow, can be part of BaseDSL
  • layout_toEndOf
  • layout_toLeftOf
  • layout_toRightOf
  • layout_toStartOf
  • layout_weight - should be also supported in v4/v7 libraries
  • layout_width

Specific to GridLayout (API level 14, can be part of BaseDSL):

  • layout_column
  • layout_columnSpan
  • layout_columnWeight
  • layout_row
  • layout_rowSpan
  • layout_rowWeight

Specific to AppBarLayout (Design support library):

  • android.support.design:layout_scrollFlags
  • android.support.design:layout_scrollInterpolator

Specific to AbsoluteLayout (deprecated):

  • layout_x
  • layout_y

@zserge
Copy link
Collaborator Author

zserge commented May 6, 2016

This narrows down the scope to:

  • Design DSL: support anchor view ID and anchor gravity for CoordinatorLayout
  • Base DSL: support DrawerLayout and CoordinatorLayout and Toolbar gravity
  • Base DSL: support SlidingPaneLayout weight
  • BaseDSL: support TableRow span (easy, but seems to be rarely used)
  • BaseDSL: support GridLayout (also, easy but seems to be rarely used)

The only possible way to mutate property of the class not known at compile time is via reflection. The performance should be an issue, since it's a one-time operation in app lifecycle (most apps have only one navigation drawer or sliding pane).

@aaronpoweruser
Copy link

AppBarLayout.LayoutParams has a layout_scrollFlags and layout_scrollInterpolator layout param

http://developer.android.com/reference/android/support/design/widget/AppBarLayout.LayoutParams.html#attr_android.support.design:layout_scrollFlags

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants