Standardized image sizes on android - android

So I'm trying to build a basic app on Android Studio 1.4.0. Yes, I know it's old, but being pretty new to app-building and having found a tutorial I thought I'd go with it.
My question: I put an image into "#drawable." How do I make sure it resizes when I select different emulators? Should I use "#mipmap?" If so, how exactly would I do that? I have different sizes for my image (xxhdpi, etc.) but I don't know how to make it so the emulator "automatically selects" the correct image size.

For adding a resource to your Project use this plugin
https://plugins.jetbrains.com/plugin/7658-android-drawable-importer
You add your img on one size example xxxhdpi and it automatically make all the resizes, then you only set #drawable/yourimage in the ImageView for example and it selects automatically the image needed for that size
And also I highly recomend you to use at least android studio 2.7+, when you decide to actualize after tutorial you'll encounter a lot of differences and too many methods deprecated

Related

QML: select image on Android (without java bridges and stuff)

I would like to select an image from existing files in an app written in Qt 5.9 (using Qt Quick and some c++). I tried to use FileDialog from QML (official example here) but when I run it in the emulator, it looks like this:
I did read this blogpost http://amin-ahmadi.com/2015/12/08/how-to-open-android-image-gallery-in-qt/ which explains how to use native code for gallery chooser though I am wondering if meanwhile Qt progressed to make such task readily available in a more straightforward manner.
EDIT: A hint is that FileDialog.shortcut documented here says:
The directory containing the user's pictures or photos. It is always a
kind of file: URL; but on some platforms, it will be specialized, such
that the FileDialog will be realized as a gallery browser dialog.
Better late than never:
Your application probably uses high DPI scaling, which automatically scales the QtQuick.Controls 2 on displays with higher DPI. In main.cpp:
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
Basically the px sizes in your app don't represent physical pixels anymore. Some (older) Qt components, one of those is the FileDialog, don't work as expected on that setting. Removing it should fix your problem, but will probably affect the visual appearance of you app. More Info: https://blog.qt.io/blog/2016/01/26/high-dpi-support-in-qt-5-6/
You could try to build your own FileDialog with the FolderListModel: https://doc.qt.io/qt-5/qml-qt-labs-folderlistmodel-folderlistmodel.html
There is also a QML component available to display and select single or multiple images. You can find more info here: https://felgo.com/updates/release-3-2-0-qt-5-12-3-subscriptions
You can also test it right on your mobile phone: https://felgo.com/web-editor/?snippet=77c7ad94

How do I get the Android Icons in Android Studio?

I'm using Android Studio, and I always see people's drawable calls to things like ic_launcher. I don't have any of these files - hell, where are they even stored? All of my few files begin with abc_ic. How would I go about getting the icons, and where would I put them?
You can get the system's drawables by
android:drawable/the_drawable_here on XML and
getResources().getDrawable(android.R.drawable.one_random_drawable,null);
programmatically.
abc_ are ActionBarCompat stuff. It's used by ActionBarCompat. For instance, you'll find the overflow icon there (the vertical dots indicating the menu).
Then there is android:drawable/ that contains the system stuff, not always convenient because it varies a lot from a version to another.
Finally, there is https://github.com/google/material-design-icons/ Pretty much all icons ever mentioned in material design are there, in black and white, in all sort of size, and for all densities.
The Android asset studio is a great tool for things like this. It will generate icons for all the main DPIs. It can be found here:
https://romannurik.github.io/AndroidAssetStudio/icons-launcher.html

android how to crop using an existent image

I need to crop an image using selectors and dragging etc.
I cannot use com.android.camera.action.CROP cause in many phones i tested doesn't work.
I searched here all examples, the only working is that where is used android.provider.MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI
but the problem is that everytime it asks user to choice the image.
Can someone post me kindly an example.
I need to open it on the image i need, without that the user has to open an image, searching in file system.
I am enough disappointed cause android doestn offer something compatible for all devices from 2.1 android till 4 at least...
Thanks
Download Sample:- https://github.com/lorensiuswlt/AndroidImageCrop
Only three changes required for android 2.1:-
In main.xml, write wrap_content instead of matchparent.
In AndroidManifest.xml, <uses-sdk android:minSdkVersion="7" />
In default.properties, target=android-7
A project is a best tutor.

Where is the drawable for the handle of a SlidingDrawer defined?

I want to use a SlidingDrawer in an activity, and I would love to just use the built-in tray handle, rather than try to find or create my own. I found it online thanks to CommonsWare but I assume that they got it from the Android platform itself, so I figure it will benefit me in the long run to know where to find it, rather than just use their copy of it. I looked for it in my Android SDK installation, under platforms/android-8/android.jar/res/ but with no success.
Where can I find the above image, in the Android SDK itself, rather than just downloading it?
Look in the launcher app: ~\platform\packages\apps\Launcher\res\drawable\handle.xml
It uses all the drawables: tray_handle_normal, tray_handle_pressed, tray_handle_selected.
may be you can type android.R.drawable... in eclipse and let the intelli-sense display all the built in drawables.
but I think it's not there cause I searched for it and didn't find it too
thanks
Be carefull with using images that come with the system. Google itself states that they will not guarantee that these images will be included in the system in every release (the name may change). Also the design of your app will change if the user uses something like Blur or Sense that overrides a lot of the standard design items. If you use a copy of the drawable itself you now how your app will look and you can be sure that your app will keep working even if the manufacturer or Google changes the images that come with a device.

Is this a built in drawable?

In this linked image , I see the button on the right quite often in a lot of apps. On my Moto Droid, it is used extensively in the settings app. It is also used as the default AlertDialog icon. Can I use this via a android.r.drawable?
The icon is built-in with the Android development, you can access the image by using R.drawable.ic_dialog_menu_generic
While it may be possible to use it via android.R.drawable, you may want to find the image in the resources that come with your SDK ($ANDROID_HOME/platforms/$VERSION/data/res, where $ANDROID_HOME is where you have the SDK installed and $VERSION is a relevant Android API level). So, per Mr. Forloney's answer, you'll find that in, say, drawable-hdpi/ic_dialog_menu_generic.png in the aforementioned directory. Then, copy that image into your project. While it will add 5K to your project size, it will mean that the icon does not change based upon OEM or Android changes.

Categories

Resources