2015-10-06 68 views
0

當我在設備上放大字體時,發生此問題,之後我不再在我的文本視圖中看到垂直滾動條。當我將字體大小更改爲小時,滾動條出現。下面是我的XML佈局看起來怎麼樣:更改Android手機上的字體大小後,在textView內啓用滾動條

  1.   <ScrollView 
           android:id="@+id/MyScrollView" 
           android:layout_height="150px" 
           android:layout_width="fill_parent"> 
          <TextView 
           android:id="@+id/title" 
           android:layout_width="wrap_content" 
           android:layout_height="wrap_content" 
           android:layout_centerHorizontal="true" android:text="xxasdasdasdxxasdasdasdxxasdasdasdxxasdasdasdxxasdasdasdxxasdasdasdxxasdasdasdxxasdasdasdxxasdasdasdxxasdasdasdxxasdasdasdxxasdasdasdxxasdasdasdxxasdasdasdxxasdasdasdxxasdasdasdxxasdasdasd." 
           android:textSize="24sp" 
           android:layout_margin="20dp" 
           android:ellipsize="marquee" 
           android:marqueeRepeatLimit="marquee_forever" 
           android:maxLines = "20" 
           android:gravity="bottom" 
           android:scrollbars="vertical" 
           android:scrollbarStyle="insideOverlay" 
           android:textColor="#676767" /> 
          <TextView 
           android:id="@+id/tv_link" 
           android:layout_width="wrap_content" 
           android:layout_height="wrap_content" 
           android:layout_below="@+id/tv_title" 
           android:layout_centerHorizontal="true" 
           android:layout_margin="5dp" 
           android:padding="5dp" 
           android:textSize="24sp" 
           android:text="Enroll Now" 
           android:textColor="#FF0C7CC0" /> 
          </ScrollView> 
    

    代碼工作正常,但只要我改變了字體大小設備上的滾動條消失

  2. 這裏是我我Activity類裏面做:

    ScrollView scroller = (ScrollView) findViewById(R.id.ScrollView01); 
        TextView tv = (TextView) findViewById(R.id.title); 
        tv.setMovementMethod(new ScrollingMovementMethod()); 
    

回答

0

應該有一個佈局將包含您的文字瀏覽,滾動視圖不能直接控制多個視圖。滾動型只能包含單一視圖,你可以做這樣的:

<ScrollView 
       android:id="@+id/MyScrollView" 
       android:layout_height="150px" 
       android:layout_width="fill_parent"> 
      <RealtiveLayout 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content"> 
      <TextView 
       android:id="@+id/title" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerHorizontal="true" android:text="xxasdasdasdxxasdasdasdxxasdasdasdxxasdasdasdxxasdasdasdxxasdasdasdxxasdasdasdxxasdasdasdxxasdasdasdxxasdasdasdxxasdasdasdxxasdasdasdxxasdasdasdxxasdasdasdxxasdasdasdxxasdasdasdxxasdasdasd." 
       android:textSize="24sp" 
       android:layout_margin="20dp" 
       android:ellipsize="marquee" 
       android:marqueeRepeatLimit="marquee_forever" 
       android:maxLines = "20" 
       android:gravity="bottom" 
       android:scrollbars="vertical" 
       android:scrollbarStyle="insideOverlay" 
       android:textColor="#676767" /> 
      <TextView 
       android:id="@+id/tv_link" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/title" 
       android:layout_centerHorizontal="true" 
       android:layout_margin="5dp" 
       android:padding="5dp" 
       android:textSize="24sp" 
       android:text="Enroll Now" 
       android:textColor="#FF0C7CC0" /> 
</RealtiveLayout> 
      </ScrollView> 
+0

如你所說......仍然沒有工作:( –

+0

嘗試刪除滾動條的風格一樣,也有沒有tv_title,這是標題更正 – Aakash