TextView पर बॉर्डर लगाना
यदि आप TextView को 3D दृश्य की तरह दिखाना चाहते हैं जैसा कि Microsoft PowerPoint के 3D टेक्स्ट में देखा जाता है, तो आप ड्रॉएबल (drawable) शेप का उपयोग करके बॉर्डर जोड़ सकते हैं।
उदाहरण: TextView पर बॉर्डर लगाना
चरण 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: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 फ़ाइल बनानी होगी।
चरण 3: ड्रॉएबल फ़ाइल बनाएं (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: रूट टैग, आकार आयत (rectangle) है।
- solid: आंतरिक भराव रंग (सफेद)।
- stroke: बॉर्डर की चौड़ाई (1dip) और रंग (#4fa5d5)।
- padding: चारों ओर पैडिंग (10dp)।
चरण 4: 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("Tutorialspoint india pvt ltd");
}
}
ऐप चलाएं
ऐप चलाएं। TextView पर बॉर्डर दिखाई देगा।

मुख्य बिंदु
- ड्रॉएबल शेप का उपयोग करके कस्टम बॉर्डर बनाया जा सकता है।
- stroke टैग बॉर्डर की चौड़ाई और रंग निर्धारित करता है।
- padding टैग टेक्स्ट और बॉर्डर के बीच जगह देता है।
- solid टैग बैकग्राउंड रंग सेट करता है।