Recently I'm studying the usage of the appcompat support library and the design support library. And I met a strange question(at least for me) that I can't understand.
In the appcompat support library, there're several AppCompat* like components, such as AppCompatButton, AppCompatCheckBox... There's one same thing among these components - In the official doc all these components have such illustration,
This will automatically be used when you use Button in your layouts.
You should only need to manually use this class when writing custom
views.
or something like this.
Here come's the question. Since Button isn't AppCompatButton, how can it consider it as AppCompatButton when I use Button during the xml or created in code? How does it work?
Forgive my Cantonese English.
Short brief on how the AppComp decided which class to init -
When using the support library (AppCompat) using the support library widgets (e.g. android,support.v4.widget.Button) ,the library will use the appropriate implementation based on your Android OS.
For example ,if your OS support Button it will use the native implementation ,else it will use the AppCompat implementation.
In other words ,it defers to run time to decide what to use..
I assume this is the automatically part..
Related
I am new to Android and i am learning SeekBars. in Google material design site i found Sliders from (com.google.android.material.slider.Slider) package instead of seekbars. I wonder what the difference is between Slider and SeekBar, which should I use and which is better? What is the purpose of implementing these two? I search a lot and There is no useful content on the internet
The following may not be entirely accurate to the last detail, but it illustrates some of the history well enough:
Slider is just the MDC version of SeekBar - named a little differently and with a lot more functionality.
First, there was only SeekBar - the original framework UI component bundled with Android.
Then, AndroidX libraries, previously called Support Libraries, were created for backporting new UI components and bugfixes to older phones which OEMs refused to update anymore. The AndroidX AppCompat subproject swaps out all your framework components for the "fixed" versions whenever you use AppCompatActivity. SeekBar -> AppCompatSeekBar, TextView -> AppCompatTextView...
The old Support Libraries also had a package named design which contained some of the then-new Material 1.0 components (CardView and whatnot) which didn't have a framework counterpart. That's the reason why there is no AppCompatCardView - because there is no framework CardView, so there is nothing to "fix" with AppCompat.
If I recall correctly, the design package of the Support Libraries later became the starting point for the Android implementation of Material Components when Material 2.0 was unveiled. Material Design has its own version of SeekBar which is called Slider and it can do everything the old Android SeekBar can plus a lot more.
As for which one to use? (Neither is "better", that kind of thinking is inapplicable)
If you're using the MDC library already, or if you need some of Slider's advanced capabilities, use Slider.
If you only need a simple line with a circle sliding between two extremes, use SeekBar instead of pulling the MDC library just for that.
I am very new to Android Development, but can I ask why the FAB is not supported in Activity and only in AppCompactActivity. Correct me if I am wrong but it's my understanding that as long as you are not bothered with backwards compatibility then using Activity is the one to use as you can directly implement material themes and use the latest material design like CardViews RecyclerViews and other layouts like CoordinatorLayout. Why then when you want to use a material design feature like the FAB does it force you to use the AppCompactActivity, I thought using the one supporting higher APIs would work. Am I missing something here, I know there are third party libs I can use, but I really need to get my head around this...
FloatingActionButton is not a part of core android library. Rather it is a part of android support design library.
compile "com.android.support:design:27.0.2"
This means this class is not pre-installed in android devices. Also to use it, your activity must use one of the AppCompat themes. Hence you need to use appcompat library to use a default FAB.
compile "com.android.support:appcompat-v7:27.0.2"
However, you can find many open source third party libraries for FAB in GitHub.
I'm studying about the layout types in Android and I started construct a floating button and I would like to know what is the best mode to create a floating button in Android Studio. Using floatingActionButton library at Android Studio or creating without libraries.
I advise you to use the support one when it answers your needs (or at least start with it until you see a major drawback).
Most of time, if the support library covers your needs, you'll be less likely to have bugs or issues with it than you would with a third party library.
I am thinking of converting my app to material design, but at the moment only a small percentage of my users are on Lollipop.
My question is, is it possible for users with kitkat and jelly bean to see the Material design?
Yes. But you will have to use latest v7 support lib to do that. Chris Banes explained it on his blog:
https://chris.banes.me/2014/10/17/appcompat-v21/
Animations on Lollipop like Ripple and similar are not included in the support lib.
There is no foolproof approach for that. You will have to use appCompat and you can get some of "materialish" features. For others like Floating Action Button, ripple etc. use Material design library. I have been using it for 3 months and found it quite useful for UI development.
you can create widget using Design Support Library (official)
http://android-developers.blogspot.in/2015/05/android-design-support-library.html
Before implementation we must following steps:-
1.Add latest support design dependency - compile 'com.android.support:design:22.2.0'
2.Your activity is extending with AppCompatActivity
List of 3rd party library`s
https://github.com/wasabeef/awesome-android-ui
Use AppCompat (from android.support) and Design (from android.support)
These libraries are Google-official
Is there a easy way to have our application look like ICS or JB?
Mainly the slider and the radio button. They look old when displayed in green.
Any hint about this?
There's a nice package available on github called HoloEverywhere.
One thing though, do not try pass it off as a ICS/JB Application, just because it "looks" like the user interface one would expect to see in a native ICS/JB Android set up.
Best that can be done with the project, is to target the latest SDK to guarantee your wide-market of Android usage, including GB.
Aim high, not low ;)
The best way is to use the Android Library 'Actionbar Sherlock'. This Library uses all native ICS Themes, etc for older devices.
ActionBarSherlock is an extension of the compatibility library designed to facilitate the use of the action bar design pattern across all versions of Android with a single API.