Any antacid drug should be taken before meals or after meals?

Both. Antacids should be taken so as not to interfere with nutrient absorption. Best time to take them is no closer than one hour before a meal and no sooner than three hours after a meal. An additional dose at bedtime can be very helpful as well.
After meals if . . . Take antacids such as calcium carbonate after meals if you notice heartburn. If you can, avoid those foods that make it worse. Stop smoking. Keep alcohol to a minimum. Stay upright as long as possible after meals. If antacids aren't enough, consider h2 blockers like ranitidine. Failing that, consider proton pump inhibitors (ppis) like omeprazole. Go see your family doc if symptoms persist.