android: tintMode: ko’rinislerge ren’ qollaw ushin isletiletug’in rejim
ImageView klasinin’ ayrim tiykarg’i usullari:
Drawable getDrawable(): Berilgan ImageView menen baylanisqan Drawable resursin qaytaradi (ya’ki ImageView ushin heshqanday resurs ornatilmag’an bolsa null )
ImageView.ScaleType getScaleType(): ImageView elementinin’ shegaralarina salistirg’anda ko’rinis qanday masshtablang’anlig’in ko‘rsetiwshi ImageView.ScaleType sanalg’an ma’nisin qaytaradi.
void setImageDrawable(Drawable drawable): Drawable obiekti ja’rdeminde ko’rinis resursin ornatadi
void setImageResource(int resId): Drawable ning resurs identifikatorinan paydalang’an halda ko’rinis resursin ornatadi
void setImageURI(Uri uri): Usi resurstin’ Uri ma’nzilinen paydalang’an halda ko’rinis resursin ornatadi
void setScaleType(ImageView.ScaleType scaleType): ko’rinis masshtabin ornatadi
void setImageAlpha(int alpha): ko’rinistin’ tiniqlig’in ornatadi - 0,0 den 1,0 ge shekem bolg’an ma’nis
Ma’selen, activity_main.xml faylinda android:scaleType atributi uchun FIT_XY ma’nisin ornatiw:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
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:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/dubi2"
android:scaleType="fitXY"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
|
Na’tiyjede, ko’rinis vertikal ha’m gorizontal tu’rde soziladi:
Salistiriw ushin, android:scaleType="center" menen uqsas misal:
Java kodindag’i uqsas misal:
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 androidx.constraintlayout.widget.ConstraintLayout;
import android.os.Bundle;
import android.widget.ImageView;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_main);
ConstraintLayout constraintLayout = new ConstraintLayout(this);
ImageView imageView = new ImageView(this);
imageView.setImageResource(R.drawable.dubi2);
//
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
ConstraintLayout.LayoutParams layoutParams = new ConstraintLayout.LayoutParams
(ConstraintLayout.LayoutParams.WRAP_CONTENT, ConstraintLayout.LayoutParams.WRAP_CONTENT);
layoutParams.leftToLeft = ConstraintLayout.LayoutParams.PARENT_ID;
layoutParams.topToTop = ConstraintLayout.LayoutParams.PARENT_ID;
imageView.setLayoutParams (layoutParams);
contraintLayout.addView(imageView);
setContentView(contraintLayout);
}
}
|
Do'stlaringiz bilan baham: |