question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for match_parent tileWidth/tileHeight

See original GitHub issue

When using attributes tileWidth or tileHeight, there should be the option to set one dimension and tell the other one to match parent’s. Right now, leaving one blank defaults to the default value (44dp), which I don’t think is what most of us want.

Reviewing https://github.com/prolificinteractive/material-calendarview/issues/132, I think it’s incorrectly closed, since the changes in 1.3 do not fix OPs original issue.

This is the part of the code that should be changed, in MaterialCalendarView.onMeasure

if (this.tileWidth > 0 || this.tileHeight > 0) {
            if (this.tileWidth > 0) {
                //We have a tileWidth set, we should use that
                measureTileWidth = this.tileWidth;
            }
            if (this.tileHeight > 0) {
                //We have a tileHeight set, we should use that
                measureTileHeight = this.tileHeight;
            }
} else ...
//if you specified width/height, measureTileSize is still -1 here
if (measureTileSize > 0) {
...
} else if (measureTileSize <= 0) {
   if (measureTileWidth <= 0) {
      //Set width to default if no value were set
      measureTileWidth = dpToPx(DEFAULT_TILE_SIZE_DP);
   }
   if (measureTileHeight <= 0) {
     //Set height to default if no value were set
     measureTileHeight = dpToPx(DEFAULT_TILE_SIZE_DP);
   }
}

I see 3 possible solutions

  1. If the user has specified height or width and the other field is -1, use measureTileWidth = desiredWidth or measureTileHeight = desiredHeight, which will result in the calendar matching parent’s dimension. This is a breaking change that may alter someone’s layout.
  2. Force the user to specify both dimensions, accepting LayoutParams.MATCH_PARENT as a valid value. As in solution 1, but we will only use desiredWidth if the user specified MATCH_PARENT
  3. Combination of 1) and 2), use default value if dimension is left blank, and accept MATCH_PARENT as a valid value.

Solution 1 is the default behaviour I’d expect from a calendar, but I guess breaking changes are to be avoided. Solution 2 will fail to compile for some users, which is good for those that upgrade without looking at the Changelog. Solution 3 is the most complete of the 3.

Maybe there are more options, but these are the ones I came up with.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
quentin41500commented, Oct 10, 2016

Fixed in v1.4.2

1reaction
Maraguescommented, Jun 23, 2016

@quentin41500 Yes, but giving a value to width/height forces the other dimension to 44dp

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to set a view's height match parent in ConstraintLayout?
Herewith, you should use 0dp instead of 'match_parent' width and constraints for each side of the child view. <android.support.constraint.
Read more >
ViewGroup.LayoutParams - Android Developers
This set of layout parameters defaults the width and the height of the children to ViewGroup. ... MATCH_PARENT and the height of each...
Read more >
How To Solve A Floor Height Problem When Tiling - YouTube
When tiling a bathroom or kitchen, you may find that the floor height after installing the new tile is higher than the adjacent...
Read more >
Daltile Ceramic & Porcelain Tile For Flooring, Walls, & More
Built on a tradition of award-winning design, trustworthy quality, and industry-leading service, browse our extensive selection of floor tile, countertops, ...
Read more >
Change the size of Tile and Tile details - TechNet - Microsoft
Hello everyone I have the following css code to change the tile size. ... If you have feedback for TechNet Subscriber Support, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found