水平滚动视图无法正确滚动

水平滚动视图无法正确滚动

本文介绍了水平滚动视图无法正确滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个水平滚动视图,它只能水平移动100 dp,而应该更宽一些,而不是滚动所有内容.我该怎么办?

I have a horizontal scroll view that moves horizontally only 100 dp while it should be much wider, not scroll all the content. What can I do?

<HorizontalScrollView
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:fillViewport="true">

    <LinearLayout
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginTop="10dp"
      android:orientation="vertical">

        <LinearLayout
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginTop="10dp"
          android:orientation="horizontal" >

           <TextView
            android:layout_width="wrap_content"
            android:layout_height="30dp"
            android:layout_marginLeft="10dp"
            android:gravity="center_vertical"
            android:text="@string/oggi"
            android:textSize="12dp" />

          <LinearLayout
            android:layout_marginLeft="10dp"
            android:layout_width="455dp"
            android:layout_height="2dp"
            android:background="#000000"
           android:layout_gravity="center"
           android:orientation="horizontal" >

          </LinearLayout>

         <TextView
           android:layout_width="wrap_content"
           android:layout_height="30dp"
           android:layout_marginLeft="10dp"
           android:gravity="center_vertical"
           android:text="@string/domani"
           android:textSize="12dp" />

       <LinearLayout
           android:layout_marginLeft="10dp"
           android:layout_width="455dp"
           android:layout_height="2dp"
           android:background="#000000"
           android:layout_gravity="center"
           android:orientation="horizontal" >
      </LinearLayout>

      <TextView
          android:layout_width="wrap_content"
          android:layout_height="30dp"
          android:layout_marginLeft="10dp"
          android:gravity="center_vertical"
          android:text="@string/prossime"
         android:textSize="12dp" />

     <LinearLayout
        android:layout_marginLeft="10dp"
        android:layout_width="400dp"
        android:layout_height="2dp"
        android:background="#000000"
        android:layout_gravity="center"
        android:orientation="horizontal" >
     </LinearLayout>

  </LinearLayout>


  <!-- Slideshow horz gridview single row -->
 <com.jess.ui.TwoWayGridView
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/dashboard_grid_giorni"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_width="match_parent"
        android:layout_height="180dp"
        android:background="#E8E8E8"
    app:cacheColorHint="#E8E8E8"
    app:verticalSpacing="0dp"
    app:horizontalSpacing="10dp"
    app:scrollDirectionPortrait="horizontal"
    app:scrollDirectionLandscape="horizontal"
    />

 </LinearLayout>

 </HorizontalScrollView>

推荐答案

我不确定100%,但您是否尝试过将您的scrollview填充为父级?如果滚动视图和布局具有相同的大小,则使用滚动视图毫无意义.ScrollView必须具有一定的大小,以便如果布局超出了滚动视图的大小,则可以滚动.

I'm not 100% sure but did you try making your scrollview fill parent? If your scrollview and your layout has the same sizes, there's no point in using a scrollview. ScrollView needs to have a size so that if the layout exceed the size of your scrollview, you can scroll.

这篇关于水平滚动视图无法正确滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 12:24