I have a ListView where each row has a fixed height.
Every row contains, next to some images, a TextView.
Sometimes, the text I want to display is too large and henc
getLineCount and getLineHieght and check if the Text is larger than the TextView.
if you use this code, the listView can be scrolled by touching anywhere other than the TextView with (boolean)isLarger = true.
text.setText(s);
text.setMaxLines(100);
text.setVerticalScrollBarEnabled(true);
text.setMovementMethod(new ScrollingMovementMethod());
OnTouchListener listener = new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
boolean isLarger;
isLarger = ((TextView) v).getLineCount()
* ((TextView) v).getLineHeight() > v.getHeight();
if (event.getAction() == MotionEvent.ACTION_MOVE
&& isLarger) {
v.getParent().requestDisallowInterceptTouchEvent(true);
} else {
v.getParent().requestDisallowInterceptTouchEvent(false);
}
return false;
}
};
text.setOnTouchListener(listener);