For Example, if you want to change package from com.example.test.myapplication to com.example.animation.myapplication .
Do below steps:
- Select below option from project pane.
fig 1
- Toggle Compact Empty Middle Packages/ Hide Empty Middle Packages as below

fig 2
3. When Toggle compact package name to Hide Empty packages package name will broken up in individual name like below.

fig 3
4. Now Click on individual directories and select Refactor using right click on directory name which you want to change or use Shift + F6 then select rename package.

Fig 4
5. Now Rename your package

fig 5
6. Select Refactor and do refactor from Find refactoring Preview in bottom of Android studio.
Now your package will rename in all places no need to worry!
Thanks !!
Good article
LikeLike