This may not seem easy, but it is actually quite simple. The answer is intention, attention and balance.
If you focus on weight, you will never find resolution. Weight in and of itself has little to do with well-being, and therefore focus on gaining/losing weight as an intention is not particularly useful (as you are finding out) - it is off-balancing.
If, however, you have an intention to enjoy a life of balance and well-being, you will gradually shift into a pattern of nourishing your body with the foods that are most appropriate/desirable for your body. A body in balance is not obese or underweight. www.enlightenedperformance.com/Enlightened
Of course it is a journey, but this gives you a starting point and a direction as you walk your path.
The intention/attention of the human consciousness is powerful. It is quantum. It will engage forces that you are not aware of, and things will begin to unfold in ways that amaze you.
I wish you well,