কম্পিউটার টিউটোরিয়াল

Android-এ CircularImageView তৈরির পদ্ধতি


এই উদাহরণটি Android-এ CircularImageView তৈরির পদ্ধতি প্রদর্শন করে।

ধাপ ১: নতুন প্রজেক্ট তৈরি করুন

Android Studio-তে File → New Project-এ যান এবং প্রয়োজনীয় বিবরণ পূরণ করে একটি নতুন প্রজেক্ট তৈরি করুন।

ধাপ ২: Gradle-এ CircularImageView লাইব্রেরি যোগ করুন

সার্কুলার ভিউ তৈরি করতে Gradle ফাইলে CircularImageView লাইব্রেরি যোগ করতে হবে:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.andy.myapplication"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    testImplementation 'junit:junit:4.12'
    implementation 'com.mikhaellopez:circularimageview:4.2.0'
    androidTestImplementation 'androidx.test:runner:1.3.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}

ধাপ ৩: MainActivity.java ফাইল

import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
}

ধাপ ৪: লেআউট ফাইল (res/layout/activity_main.xml)

<?xml version = "1.0" encoding = "utf-8"?> 
<androidx.constraintlayout.widget.ConstraintLayout 
    xmlns:android = "https://schemas.android.com/apk/res/android" 
    xmlns:app = "https://schemas.android.com/apk/res-auto" 
    xmlns:tools = "https://schemas.android.com/tools" 
    android:layout_width = "match_parent" 
    android:layout_height = "match_parent" 
    tools:context = ".MainActivity"> 
    <LinearLayout 
        android:layout_width = "match_parent" 
        android:gravity = "center_horizontal" 
        android:orientation = "vertical" 
        android:layout_height = "match_parent"> 
        <com.mikhaellopez.circularimageview.CircularImageView 
            android:layout_width = "250dp" 
            android:layout_height = "250dp" 
            android:src = "@drawable/image" 
            app:civ_border_color = "#EEEEEE" 
            app:civ_border_width = "4dp" 
            app:civ_shadow = "true" 
            app:civ_shadow_radius = "10" 
            app:civ_shadow_color = "#8BC34A"/> 
        <TextView 
            android:text = "মোহাম্মদ মোতাসিম" 
            android:layout_width = "match_parent" 
            android:layout_height = "wrap_content" 
            android:layout_marginTop = "20dp" 
            android:textSize = "20sp" 
            android:textAlignment = "center"/> 
    </LinearLayout> 
</androidx.constraintlayout.widget.ConstraintLayout>

উপরোক্ত লেআউটে CircularImageView কে com.mikhaellopez.circularimageview.CircularImageView হিসেবে ডিক্লেয়ার করা হয়েছে এবং ড্রেয়েবল থেকে ইমেজ যোগ করা হয়েছে।

অ্যাপ্লিকেশন চালান

আপনার Android ডিভাইস কম্পিউটারের সাথে সংযুক্ত আছে অনুমান করে। Android Studio-তে প্রজেক্টের যেকোনো Activity ফাইল খুলে টুলবার থেকে Run আইকনে ক্লিক করুন। আপনার মোবাইল ডিভাইস সিলেক্ট করুন এবং ডিফল্ট স্ক্রিন দেখুন।

Android-এ CircularImageView তৈরির পদ্ধতি

CircularImageView-এর বৈশিষ্ট্যাবলী

  • app:civ_border − বর্ডার তৈরি করতে ব্যবহৃত হয়, ডিফল্ট মান true

  • app:civ_border_color − বর্ডার কালার নির্ধারণ করে, ডিফল্ট কালার সাদা

  • app:civ_border_width − বর্ডারের প্রস্থ নির্ধারণ করে, ডিফল্ট মান 4dp

  • app:civ_background_color − ব্যাকগ্রাউন্ড কালার নির্ধারণ করে, ডিফল্ট কালার সাদা

  • app:civ_shadow − ইমেজের জন্য শ্যাডো তৈরি করে, ডিফল্ট মান false, শ্যাডো চাইলে true করতে হবে

  • app:civ_shadow_color − ইমেজের শ্যাডো কালার নির্ধারণ করে, ডিফল্ট কালার কালো

  • app:civ_shadow_radius − ইমেজের শ্যাডো রেডিয়াস নির্ধারণ করে, ডিফল্ট মান 8.0f

  • app:civ_shadow_gravity − ইমেজের শ্যাডো গ্র্যাভিটি নির্ধারণ করে, ডিফল্ট মান bottom

  1. অ্যান্ড্রয়েড TextView-এ ক্লিকযোগ্য লিংক তৈরি করার পদ্ধতি

  2. অ্যান্ড্রয়েড অ্যাপে GridView লেআউট তৈরির পদ্ধতি

  3. অ্যান্ড্রয়েড অ্যাপে TextToSpeech তৈরি করার পদ্ধতি

  4. Facebook-এ Android অ্যাপ তৈরি করার পদ্ধতি