Yes. You can claim an education credit such as the American Opportunity credit (Hope credit) or Lifetime Learning credit in the same year that you withdraw funds from a 529 plan. Your 529 withdrawal will not be free from federal income tax, though, if you apply the 529 withdrawal and one of these education credits against the same qualified higher education expenses.
For purposes of your 529 plan, your qualified higher education expenses are first reduced by expenses used to compute your American Opportunity credit or Lifetime Learning credit. The remaining expenses may be paid with the funds you withdraw from the 529 plan (and you won't pay any federal income taxes on those funds). You will pay federal income tax (and, in most cases, a penalty and maybe some state income taxes) on any part of your 529 plan withdrawal that remains after paying these expenses. From an income tax standpoint, it may be best for you to pay for college expenses with a combination of 529 plan withdrawals, tax credits, and other resources.
You're allowed to waive the American Opportunity credit or Lifetime Learning credit. This waiver may make sense if the value of the education credit is less than the value of federal income tax-free (and penalty-free) withdrawals from your 529 account.
Note: Investors should consider the investment objectives, risks, charges, and expenses associated with 529 plans before investing. More information about 529 plans is available in each issuer's official statement, which should be read carefully before investing. Also, before investing, consider whether your state offers a 529 plan that provides residents with favorable state tax benefits.