Let \(p(\cdot ),\ q(\cdot )\) and \(\alpha (\cdot )\) be variable exponents satisfying some Hölder continuous conditions. In this paper, the authors characterize the variable inhomogeneous Besov space \(B_{p(\cdot ),q(\cdot )}^{\alpha (\cdot )}(\mathbb {R}^n)\) and the variable inhomogeneous Triebel-Lizorkin space \(F_{p(\cdot ),q(\cdot )}^{\alpha (\cdot )}(\mathbb {R}^n)\) in terms of Hajłasz gradient, via establishing the boundedness of a kind of almost diagonal operator A on the corresponding sequence spaces.