The "measurement of length of a line" in my question is the part highlighted by a green rectangle in the following figure:

Now, I am drawing the elements (i.e. two arrows, two ends, 8) of the measurement separately. It is tedious. I wonder are there simple ways to draw these measurements? For example, \somecommand [<->, offset=x mm, "text"] (point1) -- (point2), namely \somecommand [<->, offset=2mm, "4"] (A) -- (D) or \somecommand [<->, offset=2mm, "8"] (B) -- (C) in the above figure. I would appreciate any help with this situation.
