Monday, May 14, 2018

TextView'e Scroll Ekleme

Selam Arkadaşlar;

Andoid Studio'da geliştirdiğimiz projelerde bazı durumlarda oluşturduğumuz TextView'lara scroll eklemek isteyebiliriz. Bu gönderide bu işelmin nasıl yapıldığını anltacağım.

Öncelikle .xml dosyamıza TextView ve ScrollView'ımızı ekliyoruz.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
 <ScrollView
            android:id="@+id/scrollViewCevap"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:scrollbars="vertical"
            android:fillViewport="true">

        <TextView
            android:id="@+id/text1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textSize="18dp"
            android:padding="10dp"
            android:layout_weight="20"
            android:maxLines="10"
            android:background="#FFFFFF"
            android:textStyle="bold"  />
        </ScrollView>

.java dosyamızada aşağıdaki kodları ekliyoruz;

1
2
3
 text1 = (TextView)this.findViewById(R.id.text1);
        text1.setText("Bu kısma istediğiniz text gelecektir");
text1.setMovementMethod(new ScrollingMovementMethod());

Ekran Görüntüsü:

No comments:

Post a Comment