Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is better between Activity and AppCompactActivity to use Toolbar?

When I created a new activity, it extends ActionBarActivity but it's deprecated.

At that moment, I have two options:

1) Used Activity and android:Theme.Material in my style like that :

<style name="AppTheme" parent="android:Theme.Material">

Or

2) Used AppCompatActivity and Theme.AppCompat :

<style name="AppTheme" parent="Theme.AppCompat">

So my question is, what is better between Activity and AppCompactActivity to use Android Material Design and Toolbar ?

like image 578
lopez.mikhael Avatar asked Jan 09 '23 10:01

lopez.mikhael


1 Answers

It isn't a matter of which is "better". Which one you should use depends on what versions of Android you are supporting.

Theme.Material is only available on devices running API 21 (Lollipop) and up. If you wish to use the Material theme on devices running API 20 and below, you need to use AppCompat.

When I created a new activity, it extends ActionBarActivity but it's deprecated.

This is a very recent change. As of version 22.1 of AppCompat, ActionBarActivity has been deprecated in favor of AppCompatActivity.

like image 95
Bryan Herbst Avatar answered Jan 28 '23 15:01

Bryan Herbst