I am new to Android and a little bit confused right now.
After setting up a new project with min sdk 21 (Android 5.0) in android studio, by default my main_activity
extends AppCompatActivity
which at first was no problem.
I tried to set up the Material. Dark theme like shown here but @android:style/Theme.Material
does not work with AppCompatActivity
.
It works now when main_activity
just extends Activity
.
Do I need AppCompatActivity
with min sdk 21 if I want to use features like Action Bar
or is it ok to just extend from Activity
, I thought that AppCompatActivity
& v7 Support Libraries
is there to support lower sdk versions to be able to use Material Design, what am I missing ?
If AppCompatActivity
is not needed in sdk level 21 and up why would android studio set it as default even if 21 is set as min sdk ?
I guess one main question I have is, what is the best practice for using the Material design Theme like explained here combined with AppCompatActivity which Android Studio uses by default.
Yes, you should use app compat libraries and fragments.
There are bugfixes that get bundled in the support libraries. This way Google can fix a bug in Android without having to wait for people to update their phones.
It is best practice to use the support libraries, including AppCompat and FragmentCompat
With regards to themes, your themes should look like this
<style name="AppTheme" parent="Theme.AppCompat">
see this https://medium.com/google-developers/theming-with-appcompat-1a292b754b35#.988b91sl1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With