2017-03-17 112 views
1

里面的FrameLayout滚动视图不working.I添加滚动视图框架布局内。但滚动不工作..是有没有其他可能的方式?..请建议我滚动视图无法正常工作

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
 
    android:layout_width="match_parent" 
 
    android:layout_height="match_parent"> 
 
    <FrameLayout 
 
     android:id="@+id/fragment_container" 
 
     android:layout_width="match_parent" 
 
     android:layout_height="match_parent" > 
 
     <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
 
      android:layout_width="fill_parent" 
 
      android:layout_height="wrap_content"> 
 
      <HorizontalScrollView 
 
       android:layout_width="match_parent" 
 
       android:layout_height="match_parent"> 
 
       <TableLayout android:id="@+id/maintable" 
 
        android:layout_width="fill_parent" 
 
        android:layout_height="wrap_content" 
 
        android:stretchColumns="1" > 
 

 
       </TableLayout> 
 
      </HorizontalScrollView> 
 
     </ScrollView> 
 
    </FrameLayout> 
 
</RelativeLayout>

+0

可能是因为Horizo​​ntalScrollView窃取了触摸事件。你有没有尝试删除Horizo​​ntalScrollView? – MatPag

+0

我已经尝试..不工作 – Karthik

+0

作为第一件事,将所有“fill_parent”更改为“match_parent”,因为fill_parent已弃用。作为第二件事,问题可能是ScrollView的高度。在这种情况下,真正有用的设置不同的颜色到每个布局的背景,以查看他们的开始和结束的位置,或者使用Android布局设计器中的新蓝图功能,从AS 2.3 – MatPag

回答

0

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
 
    android:gravity="center" 
 
    android:layout_width="match_parent" 
 
    android:layout_height="match_parent"> 
 

 

 
    <android.support.v7.widget.Toolbar 
 
     android:id="@+id/toolbar" 
 
     android:layout_width="match_parent" 
 
     android:layout_height="?attr/actionBarSize" 
 
     android:background="?attr/colorPrimary" 
 
     android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
 
     app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
 
     android:elevation="4dp" /> 
 

 

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

 

 
       <TableLayout android:id="@+id/maintable" 
 
        android:layout_width="match_parent" 
 
        android:layout_height="wrap_content" 
 
        android:stretchColumns="1" > 
 

 
       </TableLayout> 
 
    </FrameLayout> 
 
</ScrollView>

+0

现在它的工作 – Karthik

0

你真的需要ScrollView + Horizo​​ntalScrollView吗?

试试这个

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" android:layout_height="match_parent"> 
    <FrameLayout android:id="@+id/fragment_container" 
    android:layout_width="match_parent" android:layout_height="match_parent" > 
    <HorizontalScrollView android:layout_width="match_parent" 
    android:layout_height="match_parent"> <TableLayout android:id="@+id/maintable" 
    android:layout_width="fill_parent" android:layout_height="wrap_content" 
    android:stretchColumns="1" > </TableLayout> </HorizontalScrollView> </ 
    FrameLayout> </RelativeLayout> 
+0

我需要scrollview – Karthik

+0

在这种情况下,尝试NestedScrollView而不是FrameLayout https://developer.android.com/reference/android/support/v4/widget/NestedScrollView.html – albeee

0

需要这么做?然后使用适配器的snaphelper类。

相关问题