TextView中无法点击里面滚动型中列表视图? [英] TextView is not clickable inside scrollview in listview?
本文介绍了TextView中无法点击里面滚动型中列表视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的充气布局: -
My inflate layout:-
<FrameLayout
android:layout_width="100dip"
android:layout_height="100dip"
android:gravity="center"
android:orientation="vertical" >
<ImageView
android:id="@+id/UserImageView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/no_image"
android:gravity="center_horizontal|bottom"
android:orientation="vertical"
android:scaleType="fitXY" >
</ImageView>
<TextView
android:id="@+id/UserTitleTextView"
android:layout_width="fill_parent"
android:layout_height="25dip"
android:layout_gravity="bottom"
android:background="@android:color/transparent"
android:gravity="center_vertical"
android:paddingLeft="5dip"
android:paddingRight="28dip"
android:singleLine="true"
android:text=""
android:textColor="@android:color/white"
android:textSize="16sp" />
<ImageView
android:id="@+id/UserRecentActivityIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:layout_marginBottom="10dip"
android:layout_marginRight="8dip"
android:gravity="bottom|right" />
<ImageView
android:id="@+id/redDotActivityIconInflateGroupDetail02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:layout_marginBottom="30dip"
android:layout_marginRight="4dip"
android:gravity="bottom|right"
android:src="@drawable/red_dot_icon" />
</FrameLayout>
<RelativeLayout
android:id="@+id/RelativeLayoutMain"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="5dip"
android:layout_marginLeft="10dip"
android:layout_marginTop="5dip"
android:orientation="vertical" >
<TextView
android:id="@+id/activityTitleTextViewGroupDetail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="5dip"
android:singleLine="true"
android:text=""
android:textColor="@android:color/white"
android:textSize="15sp" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="@+id/thumbUrlImageView"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentRight="true" >
</ImageView>
</RelativeLayout>
<ImageView
android:id="@+id/ArrowImageView"
android:layout_width="15dip"
android:layout_height="20dip"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="@drawable/arrow1" />
<ScrollView
android:id="@+id/ScrollMain"
android:fillViewport="true"
android:clickable="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/activityTitleTextViewGroupDetail"
android:layout_marginTop="3dip" >
<com.example.app.EllipsizingTextView
android:id="@+id/messageTextViewGroupDetail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:paddingRight="10dip"
android:text=""
android:textColor="@android:color/white"
android:textSize="14.5sp" />
</ScrollView>
<TextView
android:id="@+id/StartDateTextViewGroupDetail02"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/ScrollMain"
android:layout_marginRight="20dip"
android:layout_marginTop="5dip"
android:text=""
android:textColor="@android:color/white"
android:textSize="12sp" />
<TextView
android:id="@+id/dateTextViewGroupDetail"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="@+id/StartDateTextViewGroupDetail02"
android:text=""
android:textColor="@android:color/white"
android:textSize="12sp" />
</RelativeLayout>
请找attaced快照
please find attaced snapshot
推荐答案
基本上在Android中,嵌套的滚动能部件不推荐使用,但是你可以使用下面代码段::
Basically in Android, nested scroll-able components are not recommended, but you can use below snippet ::
textView.setOnTouchListener(new ListView.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
int action = event.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
// Disallow ScrollView to intercept touch events.
v.getParent().getParent().getParent()
.requestDisallowInterceptTouchEvent(true);
break;
case MotionEvent.ACTION_UP:
// Allow ScrollView to intercept touch events.
v.getParent().getParent()
.requestDisallowInterceptTouchEvent(false);
break;
}
return true;
}
});
然后把,setOnClickListener对于相同的TextView,然后TextView的是滚动也clicable。
And then put, setOnClickListener for the same textView, then textview be scrollable also be clicable.
这篇关于TextView中无法点击里面滚动型中列表视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文