2016-07-04 4 views
2

私はそれの終わりに複数のTextViewsと1つのListViewコントロールを持って活動しています。 ListViewが独自のスクロールを持っていることに気付きました。リストビューのスクロールを無効にして、画面全体に対して1つのScrollViewを作成します。それをしてもいいですか?ダウンリストビューから無効にスクロール - アンドロイド

これは、活動のためのXMLです:

編集:私は、画面のためscrollViewを追加しましたが、それが唯一のリストの1つの項目を示しているので、それは何らかの形でListViewコントロールに影響を与えています。

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbarOrderDetail" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:background="@drawable/topbg" 
     android:minHeight="?attr/actionBarSize"> 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 

      <TextView 
       android:id="@+id/lblBackButtonOrderDetail" 
       android:layout_width="40dp" 
       android:layout_height="wrap_content" 
       android:layout_alignParentLeft="true" 
       android:onClick="goBackToTabs" 
       android:layout_marginTop="@dimen/margin_five" 
       android:drawableLeft="@drawable/back" /> 

      <TextView 
       android:id="@+id/lblOrderDetailHeader" 
       fontPath="fonts/Roboto-Bold.ttf" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerHorizontal="true" 
       android:text="Order Details" 
       android:textSize="21sp" /> 
     </RelativeLayout> 
    </android.support.v7.widget.Toolbar> 

    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:gravity="center|left" 
      android:orientation="vertical" 
      android:paddingLeft="8dp" 
      android:paddingRight="8dp"> 

    <TextView 
     android:id="@+id/lblOrderId" 
     fontPath="fonts/Roboto-Bold.ttf" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/toolbarOrderDetail" 
     android:layout_marginLeft="@dimen/margin_ten" 
     android:layout_marginTop="@dimen/margin_ten" 
     android:text="@string/order_id" 
     android:textSize="@dimen/activity_horizontal_margin" /> 

    <TextView 
     android:id="@+id/lblOrderIdData" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignBottom="@+id/lblOrderId" 
     android:layout_alignTop="@+id/lblOrderId" 
     android:layout_below="@+id/toolbarOrderDetail" 
     android:layout_marginLeft="@dimen/margin_ten" 
     android:layout_toRightOf="@+id/lblOrderId" 
     android:gravity="center" 
     android:text="" /> 

    <View 
     android:id="@+id/viewOrder1" 
     android:layout_width="match_parent" 
     android:layout_height="1dp" 
     android:layout_below="@+id/lblOrderId" 
     android:layout_marginTop="@dimen/margin_ten" 
     android:background="@color/line_color"></View> 

    <TextView 
     android:id="@+id/lblBeestroNameHeader" 
     fontPath="fonts/Roboto-Bold.ttf" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/viewOrder1" 
     android:layout_marginLeft="@dimen/margin_ten" 
     android:layout_marginTop="@dimen/margin_ten" 
     android:text="@string/bistro_name" 
     android:textSize="@dimen/activity_horizontal_margin" /> 

    <TextView 
     android:id="@+id/lblBistroName" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignBottom="@+id/lblBeestroNameHeader" 
     android:layout_alignTop="@+id/lblBeestroNameHeader" 
     android:layout_marginLeft="@dimen/margin_ten" 
     android:layout_toRightOf="@+id/lblBeestroNameHeader" 
     android:gravity="center" 
     android:text="" /> 

    <View 
     android:id="@+id/viewOrder2" 
     android:layout_width="match_parent" 
     android:layout_height="1dp" 
     android:layout_below="@+id/lblBeestroNameHeader" 
     android:layout_marginTop="@dimen/margin_ten" 
     android:background="@color/line_color"></View> 

    <TextView 
     android:id="@+id/lblOrderStatus" 
     fontPath="fonts/Roboto-Bold.ttf" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/viewOrder2" 
     android:layout_marginLeft="@dimen/margin_ten" 
     android:layout_marginTop="@dimen/margin_ten" 
     android:text="@string/order_status" 
     android:textSize="@dimen/activity_horizontal_margin" /> 

    <TextView 
     android:id="@+id/lblOrder" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignBottom="@+id/lblOrderStatus" 
     android:layout_alignTop="@+id/lblOrderStatus" 
     android:layout_marginLeft="@dimen/margin_ten" 
     android:layout_toRightOf="@+id/lblOrderStatus" 
     android:gravity="center" 
     android:text="" 
     android:textColor="@android:color/holo_red_light" /> 

    <View 
     android:id="@+id/viewOrder3" 
     android:layout_width="match_parent" 
     android:layout_height="1dp" 
     android:layout_below="@+id/lblOrderStatus" 
     android:layout_marginTop="@dimen/margin_ten" 
     android:background="@color/line_color"></View> 

    <TextView 
     android:id="@+id/lblPaymentMethodHeader" 
     fontPath="fonts/Roboto-Bold.ttf" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/viewOrder3" 
     android:layout_marginLeft="@dimen/margin_ten" 
     android:layout_marginTop="@dimen/margin_ten" 
     android:text="@string/payment_method" 
     android:textSize="@dimen/activity_horizontal_margin" /> 

    <TextView 
     android:id="@+id/lblPaymentMethod" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignBottom="@+id/lblPaymentMethodHeader" 
     android:layout_alignTop="@+id/lblPaymentMethodHeader" 
     android:layout_marginLeft="@dimen/margin_ten" 
     android:layout_toRightOf="@+id/lblPaymentMethodHeader" 
     android:gravity="center" 
     android:text="" /> 

    <View 
     android:id="@+id/viewOrder4" 
     android:layout_width="match_parent" 
     android:layout_height="1dp" 
     android:layout_below="@+id/lblPaymentMethod" 
     android:layout_marginTop="@dimen/margin_ten" 
     android:background="@color/line_color"></View> 

    <TextView 
     android:id="@+id/lblDate" 
     fontPath="fonts/Roboto-Bold.ttf" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/viewOrder4" 
     android:layout_marginLeft="@dimen/margin_ten" 
     android:layout_marginTop="@dimen/margin_ten" 
     android:text="Date: " 
     android:textSize="@dimen/activity_horizontal_margin" /> 

    <TextView 
     android:id="@+id/lblDateTxt" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignBottom="@+id/lblDate" 
     android:layout_alignTop="@+id/lblDate" 
     android:layout_marginLeft="@dimen/margin_ten" 
     android:layout_toRightOf="@+id/lblDate" 
     android:gravity="center" 
     android:text="" /> 

    <View 
     android:id="@+id/viewOrder5" 
     android:layout_width="match_parent" 
     android:layout_height="1dp" 
     android:layout_below="@+id/lblDate" 
     android:layout_marginTop="@dimen/margin_ten" 
     android:background="@color/line_color"></View> 

    <TextView 
     android:id="@+id/lblTime" 
     fontPath="fonts/Roboto-Bold.ttf" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/viewOrder5" 
     android:layout_marginLeft="@dimen/margin_ten" 
     android:layout_marginTop="@dimen/margin_ten" 
     android:text="Time: " 
     android:textSize="@dimen/activity_horizontal_margin" /> 

    <TextView 
     android:id="@+id/lblTimeTxt" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignBottom="@+id/lblTime" 
     android:layout_alignTop="@+id/lblTime" 
     android:layout_marginLeft="@dimen/margin_ten" 
     android:layout_toRightOf="@+id/lblTime" 
     android:gravity="center" 
     android:text="" /> 

    <View 
     android:id="@+id/viewOrder6" 
     android:layout_width="match_parent" 
     android:layout_height="1dp" 
     android:layout_below="@+id/lblTime" 
     android:layout_marginTop="@dimen/margin_ten" 
     android:background="@color/line_color"></View> 

    <TextView 
     android:id="@+id/lblTotal" 
     fontPath="fonts/Roboto-Bold.ttf" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/viewOrder6" 
     android:layout_marginLeft="@dimen/margin_ten" 
     android:layout_marginTop="@dimen/margin_ten" 
     android:text="Total Price: " 
     android:textSize="@dimen/activity_horizontal_margin" /> 

    <TextView 
     android:id="@+id/lblTotalTxt" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignBottom="@+id/lblTotal" 
     android:layout_alignTop="@+id/lblTotal" 
     android:layout_marginLeft="@dimen/margin_ten" 
     android:layout_toRightOf="@+id/lblTotal" 
     android:gravity="center" 
     android:text="" /> 

    <View 
     android:id="@+id/viewOrder7" 
     android:layout_width="match_parent" 
     android:layout_height="1dp" 
     android:layout_below="@+id/lblTotal" 
     android:layout_marginTop="@dimen/margin_ten" 
     android:background="@color/line_color"></View> 

    <TextView 
     android:id="@+id/lblItem" 
     fontPath="fonts/Roboto-Bold.ttf" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/viewOrder7" 
     android:layout_marginLeft="@dimen/margin_ten" 
     android:layout_marginTop="@dimen/margin_ten" 
     android:text="Items Ordered:" 
     android:textSize="@dimen/activity_horizontal_margin" /> 

    <TextView 
     android:id="@+id/lblItem1" 
     fontPath="fonts/Roboto-Bold.ttf" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/lblItem" 
     android:layout_marginLeft="@dimen/margin_ten" 
     android:layout_marginTop="@dimen/margin_ten" 
     android:text="Name/Quantity/Price" 
     android:textSize="@dimen/activity_horizontal_margin" /> 

    <ListView 
     android:id="@+id/list" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_below="@id/lblItem1" 
     android:layout_marginBottom="@dimen/margin_ten" 
     android:layout_marginTop="@dimen/margin_ten" 
     android:background="@android:color/transparent" 
     android:divider="@color/line_color" 
     android:dividerHeight="1dp" 
     android:scrollbars="none" /> 

    <include 
     android:id="@+id/beeGif" 
     layout="@layout/view_bee_animation" 
     android:layout_width="100dp" 
     android:layout_height="100dp" 
     android:layout_centerInParent="true"></include> 

     </LinearLayout> 

    </ScrollView> 


</LinearLayout> 

答えて

0

これは動作するはずです。返信用

listView.setOnTouchListener(new OnTouchListener() { 

    public boolean onTouch(View v, MotionEvent event) { 
     return true; 
    } 
}); 
+0

感謝。私はこれを追加しようとしましたが、うまくいきませんでした。また、ScrollViewを画面に追加しましたが、リストの最初の項目のみが表示されるため、ListViewに影響しているようです。コードを更新しました。 –

関連する問題