কম্পিউটার

অ্যান্ড্রয়েডে সীমানার মধ্যে ফিট করার জন্য টেক্সটভিউ পাঠ্যকে স্বয়ংক্রিয়ভাবে স্কেল করার সর্বোত্তম উপায় কী?


এই উদাহরণটি দেখায় কিভাবে আমি টেক্সটভিউ টেক্সটকে অ্যান্ড্রয়েডের সীমার মধ্যে ফিট করতে স্বয়ংক্রিয়ভাবে স্কেল করতে পারি।

ধাপ 1 − অ্যান্ড্রয়েড স্টুডিওতে একটি নতুন প্রকল্প তৈরি করুন, ফাইল ⇒ নতুন প্রকল্পে যান এবং একটি নতুন প্রকল্প তৈরি করতে সমস্ত প্রয়োজনীয় বিবরণ পূরণ করুন৷

build.gradle-এ নিম্নলিখিত নির্ভরতা যোগ করুন:মডিউল:অ্যাপ)

implementation 'com.android.support:design:28.0.0'
implementation 'me.grantland:autofittextview:0.2.1'

ধাপ 2 − res/layout/activity_main.xml-এ নিম্নলিখিত কোড যোগ করুন।

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="https://schemas.android.com/apk/res/android"
xmlns:tools="https://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   xmlns:autofit="https://schemas.android.com/apk/res-auto"
   android:orientation="vertical"
   tools:context=".MainActivity">
   <me.grantland.widget.AutofitTextView
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:maxLines="2"
      android:singleLine="true"
      android:text="Android AutoFit TextView Example"
      android:textSize="42sp"
      autofit:minTextSize="5sp" />
   <me.grantland.widget.AutofitTextView
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:maxLines="2"
      android:layout_marginTop="10dp"
      android:layout_marginBottom="10dp"
      android:singleLine="true"
      android:text="A TextView that automatically reSizes text to fit perfectly within the bounds"
      android:textSize="42sp"
      autofit:minTextSize="5sp" />
   <me.grantland.widget.AutofitTextView
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:maxLines="2"
      android:singleLine="true"
      android:text="Android AutoFit TextView"
      android:textSize="42sp"
      autofit:minTextSize="5sp" />
   <me.grantland.widget.AutofitTextView
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:maxLines="2"
      android:layout_marginTop="10dp"
      android:layout_marginBottom="10dp"
      android:singleLine="true"
      android:text="Automatically Resized text"
      android:textSize="42sp"
      autofit:minTextSize="5sp" />
   <me.grantland.widget.AutofitTextView
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:maxLines="2"
      android:singleLine="true"
      android:text="Automatically Resize Text to Fit Perfectly within its Bounds"
      android:textSize="42sp"
      autofit:minTextSize="5sp" />
</LinearLayout>

ধাপ 3 − src/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);
   }
}

পদক্ষেপ 4৷ − androidManifest.xml

-এ নিম্নলিখিত কোড যোগ করুন
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="https://schemas.android.com/apk/res/android" package="app.com.sample">
   <application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:supportsRtl="true"
      android:theme="@style/AppTheme">
      <activity android:name=".MainActivity">
         <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
      </activity>
   </application>
</manifest>

আপনার অ্যাপ্লিকেশন চালানোর চেষ্টা করা যাক. আমি ধরে নিচ্ছি আপনি আপনার কম্পিউটারের সাথে আপনার আসল অ্যান্ড্রয়েড মোবাইল ডিভাইসটি সংযুক্ত করেছেন৷ অ্যান্ড্রয়েড স্টুডিও থেকে অ্যাপটি চালাতে, আপনার প্রোজেক্টের অ্যাক্টিভিটি ফাইলগুলির একটি খুলুন এবং টুলবার থেকে রান আইকনে ক্লিক করুন। একটি বিকল্প হিসাবে আপনার মোবাইল ডিভাইস নির্বাচন করুন এবং তারপরে আপনার মোবাইল ডিভাইসটি পরীক্ষা করুন যা আপনার ডিফল্ট স্ক্রীন প্রদর্শন করবে -

অ্যান্ড্রয়েডে সীমানার মধ্যে ফিট করার জন্য টেক্সটভিউ পাঠ্যকে স্বয়ংক্রিয়ভাবে স্কেল করার সর্বোত্তম উপায় কী?


  1. অ্যান্ড্রয়েড অটোর 7টি সেরা বিকল্প৷

  2. সেরা ফ্রি অ্যান্ড্রয়েড লঞ্চার কি?

  3. অ্যান্ড্রয়েডের জন্য সেরা 10টি টেলিপ্রম্পটার অ্যাপ

  4. ডুপ্লিকেট ফাইলগুলি পরিচালনা করার সর্বোত্তম উপায় কী?