세로로 스크롤 할 수있는 응용 프로그램을 만들려고하고 내 ScrollView 내부에 HorizontalView를 내 TableLayout 중 일부를 스크롤하도록 지정하려면 Scrollview가 완벽하게 작동하지만 가로 스크롤 할 수 없습니다. 어떻게 해결할 수 있을까요? 당신의 도움을 주셔서 감사합니다.가로 ScrollView가 작동하지 않는 이유는 무엇입니까?
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true" >
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tablejdl"
android:weightSum="7"
android:layout_marginTop="20dp"
>
<TableRow
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:weightSum="7"
android:gravity="center_horizontal">
<TextView
android:textColor="#ffffff"
android:layout_marginTop="10dp"
android:layout_width="0dp"
android:textSize="11sp"
android:layout_height="wrap_content"
android:text="Barang"
android:layout_weight="2"
android:id="@+id/kodebar"
/>
<TextView
android:textColor="#ffffff"
android:layout_marginTop="10dp"
android:layout_width="0dp"
android:textSize="11sp"
android:layout_height="wrap_content"
android:text="Jumlah"
android:layout_weight="1"
android:id="@+id/jumlah"
/>
<TextView
android:textColor="#ffffff"
android:layout_marginTop="10dp"
android:layout_width="0dp"
android:textSize="11sp"
android:layout_height="wrap_content"
android:text="Sup1"
android:layout_weight="1"
android:id="@+id/namabar"/>
<TextView
android:textColor="#ffffff"
android:layout_marginTop="10dp"
android:layout_width="0dp"
android:textSize="11sp"
android:layout_height="wrap_content"
android:text="Sup2"
android:layout_weight="1"
android:id="@+id/jumlahbar"/>
<TextView
android:textColor="#ffffff"
android:layout_marginTop="10dp"
android:layout_width="0dp"
android:textSize="11sp"
android:layout_height="wrap_content"
android:text="Sup3"
android:layout_weight="4"
android:id="@+id/stokbar"/>
<TextView
android:textColor="#ffffff"
android:layout_marginTop="10dp"
android:layout_width="0dp"
android:textSize="11sp"
android:layout_height="wrap_content"
android:text="Total"
android:layout_weight="2"
android:id="@+id/jtotal"/>
</TableRow>
</TableLayout>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/tablejdl"
android:id="@+id/recyclerpenawaran">
</android.support.v7.widget.RecyclerView>
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/recyclerpenawaran"
android:id="@+id/tablejdl2"
android:weightSum="7"
android:layout_marginTop="15dp"
>
<TableRow
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:weightSum="7"
android:gravity="center_horizontal">
<TextView
android:textColor="#ffffff"
android:layout_marginTop="10dp"
android:layout_width="0dp"
android:textSize="11sp"
android:layout_height="wrap_content"
android:layout_weight="2"
/>
<TextView
android:textColor="#ffffff"
android:layout_marginTop="10dp"
android:layout_width="0dp"
android:textSize="11sp"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<CheckBox
android:textColor="#ffffff"
android:layout_marginTop="10dp"
android:layout_width="0dp"
android:textSize="11sp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/checksup1"/>
<CheckBox
android:textColor="#ffffff"
android:layout_marginTop="10dp"
android:layout_width="0dp"
android:textSize="11sp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/checksup2"/>
<CheckBox
android:textColor="#ffffff"
android:layout_marginTop="10dp"
android:layout_width="0dp"
android:textSize="11sp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/checksup3"/>
<TextView
android:textColor="#ffffff"
android:layout_marginTop="10dp"
android:layout_width="0dp"
android:textSize="11sp"
android:layout_height="wrap_content"
android:text="Total"
android:layout_weight="1"
android:id="@+id/total"/>
</TableRow>
</TableLayout>
</RelativeLayout>
</LinearLayout>
</HorizontalScrollView>
내 자식에게 몇 가지 코드를 추가했습니다. Scrollview 레이아웃은 스크롤 할 수 있지만 작동하지 않을 수 있습니다.
scrool = (ScrollView)findViewById(R.id.vertical);
scrollView = (HorizontalScrollView)findViewById(R.id.horizontal);
scrool.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
scrollView.getParent().requestDisallowInterceptTouchEvent(false);
return false;
}
});
scrollView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
v.getParent().requestDisallowInterceptTouchEvent(true);
return false;
}
});
당신의 HorizontalScrollView도 동일한 수직 스크롤 기능이있는 다른 스크롤에 있기 때문에. 부모 수직 스크롤링이 작동하지 않도록합니다. –
답해 주셔서 감사합니다.하지만 제 응용 프로그램에서 수직 스크롤링도하고 싶습니다. @ K.Sopheak –
recyclerview 만 사용해보십시오. horalscrollview 뷰 그룹이 필요하지 않습니다. RecyclerView에는 더 쉽게 구현할 수있는 더 새로운 메소드가 있습니다. –