I want to check this to fetch different images by internet. How to do that?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
As of 2018, you can use the below method -
But as @Ted pointed always consult the official docs before using
On some devices (mine is Galaxy Tab3), both density and densityDpi return strange values like 1.33(density), 213(densityDpi). So my solution is to add these flag :
to 4 values.xml files, put these under corresponding res/values-[xxx]/ folders.
You can check the screen density with:
EDIT Be aware that as Android evolves, other values should be included in the
switch
cases. As of this edit, this includesDisplayMetrics.DENSITY_TV
andDisplayMetrics.DENSITY_XXHIGH
. Consult the docs for the latest info; I'm not going to bother maintaining this answer.From the above answers, I combined them and created the below function:
Now, on which device you want to get the density information and which folder it will be used, just add the above method in that activity and add the below line in onCreate