Search code examples
javaandroidgridviewoverlapoverlapping

Check if a TextView text is cut off the screen



I have a calendar view which is based on a GridView.
It basically a school tests calendar. When you click on one of the cells you can see information about the test. In some phones the TextView containing the information is not shown, or partially shown because the calendar catches the whole screen. I decided that if the TextView is cut off, I want to show an AlertDialog instead of showing the information on the screen. The problem is, I don't know how to check if the TextView is cut off.
Here are 2 pictures to show you what I mean:

Thats how it should look:

Thats how it should look

Thats how it sometimes looks:

Thats how it sometimes looks

Thanks!


Solution

  • I have found a solution on my own. I checked the height of the GridView and the height of the TextView. then,

    if (gridViewHeight + textViewHeight >= containingLinearLayoutHeight)

    it means that the Text is cut off.