TextView-এ বর্ডার যোগ করার পদ্ধতি
এই উদাহরণে দেখানো হয়েছে কীভাবে TextView-এ ড্রয়েবল (drawable) ব্যবহার করে বর্ডার যোগ করা যায়, যা মাইক্রোসফট পাওয়ারপয়েন্টের ৩ডি টেক্সটের মতো দেখাবে।
ধাপ ১: প্রজেক্ট তৈরি করুন
Android Studio-তে File → New Project থেকে প্রজেক্ট তৈরি করুন।
ধাপ ২: লেআউট (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"
tools:context=".MainActivity"
android:background="#dde4dd"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="@+id/text"
android:textSize="18sp"
android:layout_width="wrap_content"
android:background="@drawable/border"
android:layout_height="wrap_content" />
</LinearLayout>
উপরের কোডে TextView-এর ব্যাকগ্রাউন্ড হিসেবে @drawable/border ব্যবহার করা হয়েছে। এখন drawable ফোল্ডারে border.xml ফাইল তৈরি করুন।
ধাপ ৩: ড্রয়েবল ফাইল (res/drawable/border.xml)
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="https://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@android:color/white" />
<stroke android:width="1dip" android:color="#4fa5d5"/>
<padding android:bottom="10dp" android:left="10dp" android:right="10dp" android:top="10dp"/>
</shape>
এখানে shape রুট ট্যাগ, আকার রেক্ট্যাঙ্গেল, সফেদ ব্যাকগ্রাউন্ড, নীল রঙের বর্ডার (১ ডিপি প্রস্থ) এবং ১০ ডিপি প্যাডিং দেওয়া হয়েছে।
ধাপ ৪: MainActivity.java
package com.example.andy.myapplication;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView textView = findViewById(R.id.text);
textView.setText("টিউটোরিয়াল পয়েন্ট ইন্ডিয়া প্রায়ভেট লিমিটেড");
}
}
ফলাফল
অ্যাপ রান করলে TextView-এ বর্ডার সহ টেক্সট দেখাবে।
