Don't be around that person all the time if you can help it. If you live with them, try to spend as much time as possible with other family members or with friends outside the home. Do something that doesn't involve the other person too much. You don't want to learn their ways of thinking and add it into your own mind
When you do spend time with them, try to have a positive attitude yourself. Balance it out! Try to think of good qualities about that person. Pay good attention. Everyone likes a bit of attention whether they think they do or not!
Be very nice to them. If they are having a problem that you know you may be able to solve, jump in, and give them a hand. Do something unexpectedly sweet, like chores for a day, invite them to watch a movie with you, take a walk together with them, or stop doing something you know annoys them.
Tell them how it is making you feel when they are negative around you. Be constructive; tell them something else they can do and or how they can change. Encourage, don't force. Most people don't like lectures on how to behave, especially when it's pointed towards them that they are horrible or so.
Make a "hot-word" like "oranges", "butterflies", "ocean soul", etc. That you agree with the person you are going to say each time you hear them say something negative - this will act as a good reminder for them and will draw their attention to their own negative comments. Some people do it by habit. In a bad way.