Bitmaps used to specify the resolution of different types of images can be stored under the -mdpi, -hdpi, -xhdpi, -xxhdpi folders, whose parent folder is also res / drawable . Each Drawable is stored as a separate file inside the res / drawable folders. In this tutorial we will talk about what Drawables are and what they are used for and how they can be used in Android .
Use drawables
To be able to access and use Drawables, we can act as a @drawable / filename. In this case, instead of filename, we must write the name of the file we want to access. It should be noted that the file name must be entered without an extension, if the file we want to access has an extension, the extension must be removed. For example, suppose we want to access the res / drawable / test.png file, in which case we have to do this @ drawable / test and delete the last extension, which is png.
like the:
<Textview xmlns: android = "http://schemas.android.com/apk/res/android"
Android: id = "@ + id / textView1"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: background = "@ drawable / hello"
Android: text = "@ string / hello_world" />
It is also worth mentioning that by using codes and through coding, Drawable can be assigned and connected to Views. Because all views accept the resource ID in front of each input parameter.
Below is the code that can show how to draw Drawables as a background to ImageView:
ImageView = (ImageView) findViewById (R.id. image);
ImageView.setImageResource (R. drawable. hello);
This code specifies how to connect the Drawable as a background or ImageView.
How to load Bitmap
Android offers the Bitmap class to be able to work with bitmaps. So it can be said that the Bitmap class was created to be able to use bitmaps. In this part of the tutorial we want to teach you how to convert Bitmap objects to Drawable or vice versa.Note that you can even load bitmap files and then convert them to Drawable objects .Below is a code that shows how to create a Bitmap object in the assets folder and assign it to ImageView. The code below can then create the Bitmap object inside the assets folder and assign it to ImageView.
Read more on:https://www.dotnek.com/Blog/Apps/what-are-drawable-in-applications-and-how-can
link:https://dotnek.mystrikingly.com/
Related link:how many apps in play store
:: برچسبها:
dotnek ,
seo ,
site ,
:: بازدید از این مطلب : 48
|
امتیاز مطلب : 0
|
تعداد امتیازدهندگان : 0
|
مجموع امتیاز : 0