How to add image to dropdown folder in ImageView in Android Studio 1.2?
Since google added a mipmap folder for launcher icons, I had problems using the drawables folder. I have manually added hdpi folders to the portable folder, but when I try to add the src path, the images won't let me browse and select them. How to add image to dropdown folder in ImageView in Android Studio 1.2?
source to share
try with this code way there are three ways to set image in ImageView
imageView.setImageResource(R.drawable.play);
or
<ImageView
android:id="@+id/ivProfileBg"
android:src="@drawable/image_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
or
<ImageView
android:id="@+id/ivProfileBg"
android:background="@drawable/image_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
source to share
Paste the PNG image into the following directory <Project-Name>\app\src\main\res\drawable\
(if the dropdown directory doesn't exist, create a new one).
now add the src attribute to the imageView as i did.
<ImageView
android:id="@+id/ivProfileBg"
android:src="@drawable/image_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
where image_name is the name of the PNG image you just pasted into the dropdown directory.
if you want to insert image in hdpi section you have to create a directory in folder res\
then path will be<Project-Name>\app\src\main\res\drawable-hdpi\
source to share
In the upper left corner of the screen, right below the Project title, there is an overview of the project (directories, files, etc.) to change from "Android" to "Project". then go to / app / src / main / res. then right click on res and create a folder to move inside! Put your case there. you can access the resource using: @drawable / ... internally when you are going to use it.
source to share
Adding an hdpi folder inside an accessible folder won't work because it won't be detected by android. For easier navigation, you can switch and view the Project Explorer from Android "to Project " as shown below:
In the project view, you can view all available folders including hdpi, mdpi, etc., for example the following path: src app / src / main / res / ...
:
source to share