2016-12-15 4 views
0

Ich mache meinen Text als Beitrag scrollen here.Scrollen Textansicht scrollt nicht in Android.

Ich glaube, ich habe gesehen, dass das erste Mal in einem anderen Layout gescrollt wurde, sogar ohne Java-Code. Aber jetzt scrollt es nicht mehr. Keine Ahnung, was damit nicht stimmt.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingTop="?attr/actionBarSize"> 

    <LinearLayout 
     android:id="@+id/scrollingTextLayout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:background="#0792B5" 
     android:gravity="center_vertical" 
     android:orientation="horizontal"> 

     <TextView 
      android:id="@+id/scrollingText" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:ellipsize="marquee" 
      android:focusable="true" 
      android:focusableInTouchMode="true" 
      android:marqueeRepeatLimit="marquee_forever" 
      android:maxLines="1" 
      android:padding="5dp" 
      android:scrollHorizontally="true" 
      android:text="The culture of India is the way of living of people of India." 
      android:textColor="#FFFFFF" 
      android:textSize="16sp" /> 

    </LinearLayout> 

    <android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/pager" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_below="@id/scrollingTextLayout" 
     android:background="@android:color/darker_gray" /> 

</RelativeLayout> 
+0

Layoutbreite setzen android: layout_width = "wrap_content" und dann versuchen – Pavya

+0

Fertig. Das Gleiche. Immer noch nicht scrollen. –

+0

Versuchen Sie mit 'textView.setSelected (true)' in Ihrem Code. Quelle: [link] (http://stackoverflow.com/a/3333855/5373110) – Meet

Antwort

1

diese Zeilen in Ihre xml gerade auf:

android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:singleLine="true" 
android:ellipsize="marquee" 
android:marqueeRepeatLimit="marquee_forever" 
android:singleLine="true" 
android:scrollHorizontally="true" 

Und in Ihrem Code:

textView.setSelected(true); 
+1

Es funktioniert, obwohl setSelected (true) nicht benötigt wird. –

+1

Ohh danke für diese Information, ich habe nie ohne es versucht ... – Bhavnik

0

diesen Code in Aktivität hinzufügen

TexView tv=findViewbyId(R.id.scrollingText); 
tv.setSelected(true); 
+0

es funktioniert nicht. Es funktioniert jetzt, als ich SingleLine zu MaxLines = "1" änderte –

1

Es jetzt ist Scrollen. Ich habe gerade geändert maxLines="1" zu singleLine="true", Sie wissen, es ist ein bisschen komisch. Ich änderte singleLine zu maxLines, weil die IDE mich vorschlug, maxLines anstelle von singleLine zu verwenden, da es bereits veraltet ist.

+1

Ja, singleLine funktioniert für den Laufschrift, obwohl es veraltet ist, nach dem Dokument MaxLines macht die TextLines so groß wie wir angegeben haben, während SingleLine bedeutet Begrenzt den Text auf eine einzelne horizontal scrollende Zeile, anstatt sie auf mehrere Zeilen zu umbrechen – Bhavnik