2017-03-09 175 views
0

這是TextView的XML代碼。但是,每當一條線走出屏幕時,我都無法水平滾動。爲什麼我不能在textview上啓用水平滾動?

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/activity_bleapp" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.inti.cmnb.bleapp.BLEApp"> 


    <HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:id="@+id/scrollLogger" 
     > 

    <TextView 
     android:id="@+id/logger" 
     android:layout_width="fill_parent" 
     android:layout_height="match_parent" 
     android:layout_above="@+id/btnTester" 
     android:scrollHorizontally="true" 
     android:focusable="true" 
     android:focusableInTouchMode="true" 
     android:layout_alignParentTop="true" /> 

    </HorizontalScrollView> 


    <Button 
     android:id="@+id/btnTester" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_toEndOf="@+id/scrollLogger" 
     android:text="SCAN" 
     android:layout_alignParentStart="true" /> 
</RelativeLayout> 

現在加入Horizo​​ntalScrollView後,它不僅水平滾動,寬度非常小,所以我可以看到更少的文本。

+0

檢查此鏈接: - http://stackoverflow.com/a/14098053/3946958 –

+0

textView不會在其視圖中應用滾動,所以它不會工作。你需要使用horizo​​ntalScrolvIew –

+0

我已經看過所有這些答案。他們都沒有工作。我會發布我的整個XML也許有一個問題。 – aarelovich

回答

0

刪除的xmlns:安卓= 「http://schemas.android.com/apk/res/android」 從Horizo​​ntalScrollView

<HorizontalScrollView 
     android:id="@+id/scrollLogger" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" > 
0

你可以選擇使用此:

 <TextView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="Put your very long text here..." 
      android:id="@+id/txtNuus" 
      android:textColor="#000000" 
      android:singleLine="true" 
      android:ellipsize="marquee" 
      android:marqueeRepeatLimit="marquee_forever" 
      android:focusable="true" 
      android:focusableInTouchMode="true" 
      android:scrollHorizontally="true" 
      android:layout_gravity="top" 
      android:gravity="center_vertical"/>