Header Ads

Android Text View Scrolling Text (Marquee)

আজকে শিখুন Android Text View তে একটি Long Text কিভাবে Automatic Scroll করে। এখানে আমি Coding সহ দিয়ে দিয়েছি।

activity_main.xml:

Design:



Text:


<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:app="http://schemas.android.com/apk/res-auto"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:padding="10dp"    android:gravity="center"    android:background="#800000"    android:layout_height="match_parent"    tools:context="com.firstapp.my.myfirstapp.MainActivity"    android:orientation="vertical">

    <TextView        android:id="@+id/textViewRef"        android:layout_width="match_parent"        android:layout_height="70dp"        android:layout_marginTop="10dp"        android:padding="10dp"        android:lines="1"        android:layout_alignParentRight="true"        android:ellipsize="marquee"        android:fadingEdge="horizontal"        android:marqueeRepeatLimit="marquee_forever"        android:scrollHorizontally="true"        android:gravity="center"        android:text="Android Application Development Tutorial TextView Marquee"        android:textColor="#ffffff"        android:textSize="30dp" />

</LinearLayout>




MainActivity.java:



package com.firstapp.my.myfirstapp;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    TextView tv;

    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        tv = (TextView) this.findViewById(R.id.textViewRef);
        tv.setSelected(true);
        tv.setEllipsize(TextUtils.TruncateAt.MARQUEE);
        tv.setSingleLine(true);
        //tv.setText("");
    }
}

Result:



Ok বন্ধুরা Try করুন। না বুজলে Commend করুন। Thank You.


আমার সব Blog দেখুন এখানে

No comments

Powered by Blogger.