【问题标题】:ScrollView with ListView not working correctly in landscape mode带有 ListView 的 ScrollView 在横向模式下无法正常工作
【发布时间】:2016-05-11 19:16:54
【问题描述】:

我正在学习 Android 应用程序开发,我必须在其中显示内容和相关预告片。
为了显示文本内容,我使用了ScrollView,但根据文档ScrollView 无法正常工作。
我尝试使用LinearLayout 修复它,它在纵向模式下工作正常,但在横向模式下不行。我附上了图片以直观地解释它。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:weightSum="1">


    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="Large Text"
        android:id="@+id/title"
    android:background="@android:color/holo_red_dark"
    android:textColor="#ffffff"
        android:layout_gravity="center_horizontal"
        android:layout_weight="0.07"
        android:textSize="@dimen/abc_text_size_display_1_material" />

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="421dp"
        android:id="@+id/scrollView"
        android:layout_gravity="center_horizontal">

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

            <LinearLayout
                android:orientation="horizontal"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/imageView"
                    android:paddingLeft="20dp"
                    android:paddingRight="40dp"
                    android:paddingTop="5dp"
                    android:paddingBottom="20dp" />
                <RelativeLayout
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent">
                    <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/releaseDate"
                    android:text="text"


                        android:textSize="@dimen/abc_text_size_large_material"
                        android:layout_marginBottom="@dimen/design_appbar_elevation"
                        android:layout_marginTop="15dp" />
                    <TextView
                    android:layout_below="@id/releaseDate"
                    android:id="@+id/voteAverage"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="text2"
                    />



                </RelativeLayout>

            </LinearLayout>

            <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:id="@+id/plotSynopsis"

            android:text="@string/plot_synopsis"
            android:textColor="@android:color/background_dark"
            android:paddingLeft="5dp" />


            <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/overView"
            android:textColor="#616161"
            android:padding="@dimen/abc_text_size_body_2_material" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:text="Trailers:"
                android:id="@+id/trailersView"
                android:paddingLeft="5dp" />

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

                <ListView
                    android:layout_width="match_parent"
                    android:layout_height="92dp"
                    android:id="@+id/movie_list_view" />
            </LinearLayout>



        </LinearLayout>
    </ScrollView>

</LinearLayout>

【问题讨论】:

  • 某些底部无法横向滚动,是您的问题吗?
  • 是的。由于底部有列表视图以显示预告片链接@Masum
  • 您的描述标题用作列表视图标题而不是滚动视图。
  • 但是情节提要不是列表的一部分,将其限制为列表将限制未来的修改。此问题的任何其他或标准解决方案@Masum

标签: android android-layout listview scrollview


【解决方案1】:
Yes scroll view not working fine with listview you can use recyclerview on the place of listview that will be working fine and scroll smoothly.



 <android.support.v7.widget.RecyclerView
                    android:id="@+id/profile_grid_images"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_below="@+id/text_recent"
                    app:layout_behavior="@string/appbar_scrolling_view_behavior" />

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-09
    • 1970-01-01
    • 1970-01-01
    • 2020-05-15
    • 1970-01-01
    相关资源
    最近更新 更多