Arnawli bilimlendiriw ministrligi


Assets papkasinan su’wretler



Download 0,57 Mb.
bet8/9
Sana21.04.2022
Hajmi0,57 Mb.
#571328
1   2   3   4   5   6   7   8   9
Bog'liq
Satbaeva Dilfuza (Mobil)4-Kursj

Assets papkasinan su’wretler


Joqaridag’ilarda joybardag’i ko’rinisler derek sipatinda res/drawables papkasina jaylastirilg’an ha’m ImageView elementinde ko'rsetilgen. Biraq, su’wretlerdi printsipial tu’rde usi papkag’a jaylastiriw sha’rt emes. Fayllar, sonday-aq, assets papkasinda jaylasqan boliwi mu’mkin . Kelin’, bunday grafikaliq fayllar menen qanday islewdi ko'rip shig’ayiq.


Da’slep joybarg’a assets papkasin qosamiz. Bunin’ ushin Android Studio-da app katalogin basamiz ha’m payda bolg’an kontekst menyusinan New - > Directory - di tan’laymiz:

Son’ payda bolg’an aynada src\main\assets elementin tan’laymiz ha’m oni joybarg’a qosiw ushin Enter tu’ymesin basamiz:



Usi papkag’a bir neshe su’wret qosamiz:



Son’ payda bolg’an aynada src\main\assets elementin tan’laymiz ha’m oni joybarg’a qosiw ushin Enter tu’ymesin basamiz:



Usi papkag’a bir neshe su’wret qosamiz:






Son’ payda bolg’an aynada src\main\assets elementin tan’laymiz ha’m oni joybarg’a qosiw ushin Enter tu’ymesin basamiz:

Usi papkag’a bir neshe su’wret qosamiz:



Son’ payda bolg’an aynada src\main\assets elementin tan’laymiz ha’m oni joybarg’a qosiw ushin Enter tu’ymesin basamiz:



Usi papkag’a bir neshe su’wret qosamiz:



Son’ activity_main.xml faylida ImageView elementin aniqlaymiz:



1
2
3

4


5
6
7
8
9
10
11
12
13
14
15
16

17
18




xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:id="@+id/image"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_margin="16dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />


Assets papkasinan MainActivity – dag’i ImageView elementine su’wret ju’kleymiz:



1
2
3
4
5
6
7
8
9
10
11
12
13
14

15


16
17
18
19

20
21


22


23
24

25
26


27
28
29
30

package com.example.viewapp;
import androidx.appcompat.app.AppCompatActivity;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.widget.ImageView;
import java.io.IOException;
import java.io.InputStream;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ImageView imageView = findViewById(R.id.image) ;
String filename = "dubi2.png";
try(InputStream inputStream = getApplicationContext().getAssets().open(filename)){
Drawable drawable = Drawable.createFromStream(inputStream, null);
imageView.setImageDrawable(drawable);
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
}
catch (IOException e){
e.printStackTrace();
}
}
}

Fayldi ju’klep aliw ushin getApplicationContext()getAssets(). open(filename) ma’nisi ja’rdeminde InputStream ag’imin aliwimiz kerek .


Drawable.createFromStream(inputStream, null) ni shaqiriw kiriw ag’iminan Drawable obiektini jaratadi.
imageView.setImageDrawable(d) usuli Drawable -di ImageView -g’a ju’kleydi .




Download 0,57 Mb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7   8   9




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish