我正在RelativeLayout内使用ScrollView,并为RelativeLayout分配了onClickLIstener。
我正在使用以下代码。 Layout文件
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/row2_lnr_layout_ver">
<ScrollView
android:id="@+id/row2_scrollview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fadeScrollbars="false"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:scrollbars="vertical"
android:fillViewport="true">
<TextView
android:id="@+id/sa_sub_txt_view_2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="10dp"
android:layout_weight="0.4"
android:paddingLeft="10dp"
android:text="hjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj"
android:textColor="@android:color/black">
</TextView>
</ScrollView>
</RelativeLayout>
在OnCreate()中的Java文件
((RelativeLayout)findViewById(R.id.row2_lnr_layout_ver)).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Log.i("MainActivity", "onSmartActionClicked");
Toast.makeText(getApplicationContext(), "Clicked", Toast.LENGTH_SHORT).show();
}
});
当我点击 TextView 或 ScrollView 时,它不会显示 Toast。但是当我移除 ScrollView 并点击 TextView 时,它就能正常工作。有人能告诉我为什么在使用 ScrollView 时会出现这种奇怪的行为吗?