एंड्रॉइड में लॉन्चर लार्ज आइकन आकार प्राप्त करना
यह ट्यूटोरियल दिखाता है कि ActivityManager.getLauncherLargeIconSize() का उपयोग करके लॉन्चर/होम स्क्रीन पर उपयोग होने वाले बड़े आइकन का आकार कैसे प्राप्त करें।
चरण 1: नया प्रोजेक्ट बनाएं
Android Studio में File → New Project चुनें।
चरण 2: लेआउट (res/layout/activity_main.xml)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:gravity="center"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:id="@+id/text"
android:textSize="20sp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:padding="16dp" />
</LinearLayout>
चरण 3: MainActivity कोड (java/MainActivity.java)
package com.example.myapplication;
import android.app.ActivityManager;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.widget.TextView;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
TextView textView;
@RequiresApi(api = Build.VERSION_CODES.N) // API 24+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView = findViewById(R.id.text);
ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
// लॉन्चर लार्ज आइकन आकार प्राप्त करें
android.graphics.Point iconSize = activityManager.getLauncherLargeIconSize();
if (iconSize != null) {
String info = String.format(
"लॉन्चर लार्ज आइकन आकार:\nचौड़ाई: %d px\nऊंचाई: %d px",
iconSize.x, iconSize.y
);
textView.setText(info);
} else {
textView.setText("लॉन्चर आइकन आकार उपलब्ध नहीं");
}
}
}
थंबनेल आकार vs लॉन्चर आइकन आकार
| API | उपयोग | सामान्य आकार |
|---|---|---|
getAppTaskThumbnailSize() | रीसेंट ऐप्स/ओवरव्यू थंबनेल | 192x192, 256x256, 384x384 |
getLauncherLargeIconSize() | होम स्क्रीन ऐप आइकन (लार्ज) | 192x192, 256x256, 320x320 |
getLauncherIconSize() (डिप्रिकेटेड) | पुराना लॉन्चर आइकन | 48x48, 72x72, 96x96 |
उपयोग केस
- कस्टम लॉन्चर/होम स्क्रीन विकसित करना
- एडाप्टिव आइकन सही आकार में जनरेट करना
- शॉर्टकट आइकन आकार मिलान
- विजेट प्रीव्यू आकार
एडाप्टिव आइकन (आधुनिक मानक)
<!-- res/mipmap-anydpi-v26/ic_launcher.xml -->
<adaptive-icon xmlns:android="...">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
<monochrome android:drawable="@drawable/ic_launcher_monochrome" />
</adaptive-icon>
ऐप टेस्ट करें
चलाएं - लॉन्चर लार्ज आइकन की चौड़ाई और ऊंचाई पिक्सेल में दिखेगी।