6

私は、ヘッダー、その下にバナー、そしてバナーの下に2つのListViewを持つレイアウトを作成しようとしています。ヘッダーを除いて、完全な画面をスクロール可能にしたい。今私はListViewは、すべての項目を表示するのに十分なListViewの高さを設定したので、ScrollView内でスクロールしないことを知っている。問題は、これらの変更の後でも、ListViewが独立してスクロールしており、完全な画面がスクロールできないことがわかります。Android:ScrollViewはスクロールしていません

`

<include 
    android:id="@+id/logo_header" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    layout="@layout/screen_header" /> 

<ScrollView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fillViewport="true"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"> 

     <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:orientation="vertical" 
      android:layout_weight="0.8" 
      android:background="#f2f2f2"> 

      <include 
       android:id="@+id/mcUser" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       layout="@layout/complaint_reporters_details" 
       android:layout_weight="2" /> 

      <LinearLayout 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:orientation="horizontal" 
       android:weightSum="9" 
       android:layout_weight="2"> 

       <LinearLayout 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:orientation="vertical" 
        android:weightSum="1" 
        android:layout_weight="3" 
        android:focusableInTouchMode="false" 
        android:paddingLeft="30dp" 
        android:paddingRight="30dp"> 

        <ImageView android:id="@+id/mcShowList" 
         android:layout_width="fill_parent" 
         android:layout_height="fill_parent" 
         android:gravity="center" 
         android:layout_marginTop="5dp" 
         android:layout_marginBottom="5dp" 
         android:scaleType="fitXY" 
         android:src="@drawable/list_icon" 
         android:layout_weight="0.2" /> 

        <TextView android:id="@+id/mcShowList_label" 
         android:layout_width="fill_parent" 
         android:layout_height="fill_parent" 
         android:gravity="center" 
         android:textStyle="bold" 
         android:textSize="12sp" 
         android:textColor="#929292" 
         android:maxLines="1" 
         android:text="List" 
         android:layout_weight="0.8" 
         android:layout_marginTop="-8dp" /> 

       </LinearLayout> 

       <LinearLayout 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:orientation="vertical" 
        android:weightSum="1" 
        android:layout_weight="3" 
        android:gravity="center_vertical|center_horizontal" 
        android:paddingLeft="30dp" 
        android:paddingRight="30dp"> 

        <ImageView android:id="@+id/mcShowMap" 
         android:layout_width="fill_parent" 
         android:layout_height="fill_parent" 
         android:gravity="center" 
         android:layout_marginTop="5dp" 
         android:layout_marginBottom="5dp" 
         android:scaleType="fitXY" 
         android:src="@drawable/map_view" 
         android:layout_weight="0.2"/> 

        <TextView android:id="@+id/mcShowMap_label" 
         android:layout_width="fill_parent" 
         android:layout_height="fill_parent" 
         android:gravity="center" 
         android:textStyle="bold" 
         android:textSize="12sp" 
         android:textColor="#929292" 
         android:maxLines="1" 
         android:text="Map" 
         android:layout_weight="0.8" 
         android:layout_marginTop="-8dp" /> 
       </LinearLayout> 

       <LinearLayout 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:orientation="vertical" 
        android:weightSum="1" 
        android:layout_weight="3" 
        android:focusableInTouchMode="false" 
        android:paddingRight="30dp" 
        android:paddingLeft="30dp"> 

        <ImageView android:id="@+id/mcShowAnalytics" 
         android:layout_width="fill_parent" 
         android:layout_height="fill_parent" 
         android:gravity="center" 
         android:layout_marginTop="5dp" 
         android:layout_marginBottom="5dp" 
         android:scaleType="fitXY" 
         android:src="@drawable/analytics_icon" 
         android:layout_weight="0.2" /> 

        <TextView android:id="@+id/mcShowAnalytics_label" 
         android:layout_width="fill_parent" 
         android:layout_height="fill_parent" 
         android:gravity="center" 
         android:textStyle="bold" 
         android:textSize="12sp" 
         android:textColor="#929292" 
         android:maxLines="1" 
         android:text="Analytics" 
         android:layout_weight="0.8" 
         android:layout_marginTop="-10dp" /> 

       </LinearLayout> 

      </LinearLayout> 

     </LinearLayout> 

     <RelativeLayout 
      android:layout_weight="0.2" 
      android:layout_width="fill_parent" 
      android:layout_height="400dp"> 

      <FrameLayout 
       android:id="@+id/mcMapContainer" 
       android:layout_width="match_parent" 
       android:layout_height="fill_parent"/> 

      <LinearLayout 
       android:id="@+id/mcAnalyticsContainer" 
       android:orientation="vertical" 
       android:layout_width="match_parent" 
       android:layout_height="fill_parent"> 

       <FrameLayout 
        android:id="@+id/mcChartContainer" 
        android:layout_gravity="center" 
        android:layout_width="200dp" 
        android:layout_height="200dp"/> 

       <GridView 
        android:id="@+id/mcAmenityList" 
        android:layout_height="0dp" 
        android:layout_weight="7" 
        android:layout_width="match_parent" 
        android:numColumns="3"/> 

      </LinearLayout> 

      <LinearLayout 
       android:id="@+id/mcListContainer" 
       android:orientation="vertical" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:weightSum="1"> 

       <TextView 
        android:text="Open Complaints" 
        android:textColor="@color/red_btn_bg_color" 
        android:textSize="18dp" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:gravity="center_vertical|center_horizontal" 
        android:padding="5dp" /> 

       <ListView 
        android:id="@+id/mcListOpen" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content"/> 

       <TextView 
        android:text="Closed Complaints" 
        android:textColor="@color/red_btn_bg_color" 
        android:textSize="18dp" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:gravity="center_vertical|center_horizontal" 
        android:padding="5dp" /> 

       <ListView 
        android:id="@+id/mcListClosed" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content"/> 

      </LinearLayout> 

     </RelativeLayout> 

    </LinearLayout> 

</ScrollView> 

`

+0

(https://stackoverflow.com/questions/30282580/scrollview-not-scrolling [別のビューを追加する]以下の記事で私の答えを参照してください-android) –

+0

別の質問で私の答えを見てください.. [別の空のビューを追加](https://stackoverflow.com/questions/30282580/scrollview-not-scrolling-android) –

答えて

7

の変更高さ以下のようにそれを含めます。スクロールビューは、その全高さが親ビューの高さよりも大きい場合にのみ、スクロールを有効にするためです。つまり、このコードで

<ScrollView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fillViewport="true"> 

を置き換える:

<ScrollView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:fillViewport="true"> 
+0

レイアウトの高さと幅の両方を "wrap_content"にしました。スクロールしても機能しません。 – vaibhav

+1

線形レイアウトの高さをwrap_contentに変更してから試してください。 –

+0

私はそれをしました。しかし、ちょうど、ListViewを持つRelativeLayoutの高さが修正されたことに気付きました。それを "fill_parent"に変更することで問題が解決されました。 – vaibhav

0

あなたは、私はいくつかのアプリに以下の方法を複数回使用しました

listView.setOnTouchListener(new OnTouchListener() { 

public boolean onTouch(View v, MotionEvent event) { 
    if (event.getAction() == MotionEvent.ACTION_MOVE) { 
     return true; 
    } 
    return false; 
    } 
    }); 
2

、これを試すことができます。このようなものを使用し、代わりに年代を使用するのでは、あなたのレイアウトに続いて

package com.yourcompany.appname.views; 

import android.content.Context; 
import android.util.AttributeSet; 
import android.view.ViewGroup; 
import android.widget.ListView; 

public class NonScrollableListView extends ListView { 
    public NonScrollableListView(Context context) { 
     super(context); 
    } 

    public NonScrollableListView(Context context, AttributeSet attrs) { 
     super(context, attrs); 
    } 

    public NonScrollableListView(Context context, AttributeSet attrs, int defStyle) { 
     super(context, attrs, defStyle); 
    } 

    @Override 
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 
     int heightMeasureSpec_custom = MeasureSpec.makeMeasureSpec(
       Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); 
     super.onMeasure(widthMeasureSpec, heightMeasureSpec_custom); 
     ViewGroup.LayoutParams params = getLayoutParams(); 
     params.height = getMeasuredHeight(); 
    } 
} 

: 私は、ListViewコントロールの特殊なサブクラスを使用

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical"> 
    <com.yourcompany.appname.views.NonScrollableListView 
     android:id="@+id/listId" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     /> 
</LinearLayout> 

・ホープ、このことができます!

別のXMLへ
+0

ありがとうジョナサン。これにより、ListViewが完全に拡張されています。これは以前もやっていたことですが、これはより明確で明確な方法です。しかし、今でもScrollViewは私のためにスクロールせず、画面に収まるアイテムしか見ることができません。 – vaibhav

+0

@vaibhavの場合、相対ビューで高さを400dpに設定しています。それはwrap_contentなので、スクロールビューでスクロールするものがあるでしょうか?一般に、スクロールビューのビューは、コンテンツを垂直方向にラップして、スクロールビューによって与えられる余分な垂直スペースを使用する必要があります。 – Jon

+0

それは正しいです。私は昨日それを理解して固定しました。助けてくれてありがとう。残念ながら、私はあなたの答えをupvoteするのに十分な評判のポイントを持っていません。 – vaibhav

0

プットリストビューとmatch_parentからwrap_contentへスクロールビューの

<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"> 
<include layout="@layout/show_message_header" /> 
    <ScrollView 
     android:id="@+id/myscrollview_Show_message" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="@dimen/header" 
     android:fadingEdge="none" 
     android:fillViewport="false" 
     android:paddingRight="0dp" 
     android:scrollbarAlwaysDrawVerticalTrack="false" 
     android:scrollbarSize="0dp" 
     android:scrollbarStyle="insideOverlay" 
     android:scrollbars="none" > 
     <TableLayout 
      android:id="@+id/Show_message_dynamic_table" 
      android:layout_width="match_parent" 
      android:layout_height="fill_parent" > 
      <include layout="@layout/desinglayoutforlistviewincludehere" /> 
     </TableLayout> 
    </ScrollView> 

関連する問題