【问题标题】:Android HorizontalScrollViewAndroid 水平滚动视图
【发布时间】:2019-03-12 02:51:02
【问题描述】:

我正在前一个屏幕上制作一个水平滚动的片段。 Horizo​​ntalScrollView 在一个片段中 当它是一个活动时它工作得很好,但是当你将它更改为一个片段时,界面就会卡住

我的 ViewPager 中有一个 Horizo​​ntalScrollView。 但是当将其放入片段时,界面无法正常工作,但在将视图向右或向左移动时,它仍保留为图像

如下图所示。

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

    <HorizontalScrollView
        android:id="@+id/horizontalScrollView1Tar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/secondary_text_light"
        android:fadeScrollbars="false"
        android:scrollbarSize="2dp"
        android:scrollbarThumbHorizontal="@drawable/border_scroll_listview">

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

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

                <LinearLayout
                    android:layout_width="150dp"
                    android:layout_height="match_parent"
                    android:gravity="center">

                    <TextView
                        android:id="@+id/lblTarCampo1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/LayoutTar_lblTarCampo1" />

                </LinearLayout>

                <LinearLayout
                    android:layout_width="80dp"
                    android:layout_height="match_parent"
                    android:gravity="center">

                    <TextView
                        android:id="@+id/lblTarCampo2"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/LayoutTar_lblTarCampo2" />

                </LinearLayout>

                <LinearLayout
                    android:layout_width="150dp"
                    android:layout_height="match_parent"
                    android:gravity="center">

                    <TextView
                        android:id="@+id/lblTarCampo3"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/LayoutTar_lblTarCampo3" />

                </LinearLayout>

                <LinearLayout
                    android:layout_width="30dp"
                    android:layout_height="wrap_content">

                    <TextView
                        android:id="@+id/lblEspacio1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/LayoutTar_FormatoTar_txtTarSubCampo3" />

                </LinearLayout>

                <LinearLayout
                    android:layout_width="150dp"
                    android:layout_height="match_parent"
                    android:gravity="center">

                    <TextView
                        android:id="@+id/lblTarSubCampo3"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/LayoutTar_lblTarSubCampo345" />

                </LinearLayout>

                <LinearLayout
                    android:layout_width="150dp"
                    android:layout_height="match_parent"
                    android:gravity="center">

                    <TextView
                        android:id="@+id/lblTarCampo4"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/LayoutTar_lblTarCampo4" />

                </LinearLayout>

                <LinearLayout
                    android:layout_width="30dp"
                    android:layout_height="wrap_content">

                    <TextView
                        android:id="@+id/lblEspacio2"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/LayoutTar_FormatoTar_txtTarSubCampo4" />

                </LinearLayout>

                <LinearLayout
                    android:layout_width="150dp"
                    android:layout_height="match_parent"
                    android:gravity="center">

                    <TextView
                        android:id="@+id/lblTarSubCampo4"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/LayoutTar_lblTarSubCampo345" />

                </LinearLayout>

                <LinearLayout
                    android:layout_width="150dp"
                    android:layout_height="match_parent"
                    android:gravity="center">

                    <TextView
                        android:id="@+id/lblTarCampo5"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/LayoutTar_lblTarCampo5" />

                </LinearLayout>

                <LinearLayout
                    android:layout_width="30dp"
                    android:layout_height="wrap_content">

                    <TextView
                        android:id="@+id/lblEspacio3"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/LayoutTar_FormatoTar_txtTarSubCampo5" />

                </LinearLayout>

                <LinearLayout
                    android:layout_width="150dp"
                    android:layout_height="match_parent"
                    android:gravity="center">

                    <TextView
                        android:id="@+id/lblTarSubCampo5"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/LayoutTar_lblTarSubCampo345" />

                </LinearLayout>

            </LinearLayout>

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

                <ListView
                    android:id="@+id/lst_PuntoArtFon1"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:fadeScrollbars="false"
                    android:scrollbarThumbVertical="@drawable/border_scroll_listview"
                    tools:listitem="@layout/formato_tar_layout"></ListView>

            </LinearLayout>

        </LinearLayout>

    </HorizontalScrollView>

</LinearLayout>

【问题讨论】:

标签: java android horizontalscrollview


【解决方案1】:

背景颜色:白色,可点击=真。这将解决您的问题

【讨论】:

    【解决方案2】:

    发生这种情况是因为您正在加载的新视图(通过向右/向左滑动)位于 Horizo​​ntalScrollView 上方,并且其背景颜色是透明的。您必须为所有片段的父 LinearLayout 赋予白色背景色。

    还将 android:clickable 设置为 true 以便触摸事件不会触发之前的片段。

    【讨论】:

      【解决方案3】:

      背景颜色:白色,点击事件为真。这可能会解决您的问题

      【讨论】:

        猜你喜欢
        • 2012-10-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-07-18
        相关资源
        最近更新 更多