You should read booklet AN, there is detailed information about absences:
https://www.gov.uk/government/uploads/s ... r_2016.pdf
(Section 5)
This is also important:
"You must have been physically present in England, Wales, Scotland,
Northern Ireland, the Isle of Man or the Channel Islands on the day 5
years before the application is received by the Home Office." (or 3 years if applying as the spouse of civil partner of a BC)
All information given is just my opinion as a member of this forum and does not constitute immigration advice.