簡體   English   中英

Android Horizo​​ntalScrollView

[英]Android HorizontalScrollView

我在前一個屏幕上使用水平滾動片段。 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>

使背景顏色:白色,並且clickable = true。 這將解決您的問題

發生這種情況是因為您正在加載的新視圖(通過向右/向左滑動)位於Horizo​​ntalScrollView上方,並且其背景色是透明的。 您必須為所有片段的父級LinearLayout提供白色背景色。

還要將android:clickable設置為true,以便觸摸事件不會觸發先前的片段。

將背景顏色設為白色,然后將事件單擊為true。 這可以解決您的問題

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM