2014-08-31 6 views
6

है जिसमें मैंने टेक्स्टव्यू बनाया है जहां टेक्स्ट स्वचालित रूप से वर्टिकल स्क्रॉल करना शुरू करता है, जैसे मूवी में अंतिम क्रेडिट। टेक्स्ट में वेबसाइट के लिए एक लिंक है। पाठ सुचारू रूप से स्क्रॉल करता है और लिंक वेब ब्राउज़र खोलता है।स्वचालित वर्टिकल स्क्रॉलिंग टेक्स्टव्यू जिसमें एक वेबसाइट लिंक

हालांकि, जब लिंक क्लिक किया जाता है, तो पाठ टेक्स्टव्यू के नीचे नीचे स्क्रॉलिंग शुरू होता है, जहां यह बंद हो जाता है।

मैं चाहता हूं कि पाठ स्क्रॉलिंग जारी रहे, भले ही लिंक क्लिक किया गया हो। क्या करना है?

पाठ बॉक्स लेआउट (activity_main.xml):

<TextView 
    android:id="@+id/text_box" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:maxLines="6" 
    android:text="@string/text" /> 

पाठ स्क्रॉल किया जा करने के लिए (strings.xml):

<string name="text"> 
    bla bla\nlotsa bla\n\n<a href="http://www.stackoverflow.com">stackoverflow.com</a> 
</string> 

पाठ बॉक्स और स्क्रोलर (MainActivity.java):

private TextView mTextBox; 
private Scroller mTextScroller; 

mTextBox = (TextView) findViewById(R.id.text_box); 
mTextBox.setMovementMethod(LinkMovementMethod.getInstance()); // Making the link clickable 
mTextScroller = new Scroller(this, new LinearInterpolator()); // Create new scroller 
mTextBox.setScroller(mTextScroller); // Set the scroller to the text view 

पाठ स्क्रॉल शुरू (MainActivity.java) बनाने के लिए:

int startY = mTextBox.getHeight(); 
int lineHeight = mTextBox.getLineHeight(); 
int lineCount = mTextBox.getLineCount(); 
int duration = 10000; // Milliseconds 
int startX = 0; 
int dx = 0; 
int dy = startY + lineHeight * lineCount; 

mTextScroller.startScroll(startX, -startY, dx, dy, duration); 

उत्तर

0

एक समाधान टेक्स्टव्यू के सामने एक बटन रखना और बटन के लिए setOnClickListener() करना है ताकि टेक्स्ट व्यू को इंटरैक्शन प्राप्त न हो। मुझे लगता है कि समस्या पर टेक्स्टव्यू के फोकस के साथ समस्या बदल रही है। मैं गलत हो सकता हूं लेकिन आप इस दृष्टिकोण को आजमा सकते हैं

संबंधित मुद्दे