【发布时间】:2019-03-12 02:51:02
【问题描述】:
我正在前一个屏幕上制作一个水平滚动的片段。 HorizontalScrollView 在一个片段中 当它是一个活动时它工作得很好,但是当你将它更改为一个片段时,界面就会卡住
我的 ViewPager 中有一个 HorizontalScrollView。 但是当将其放入片段时,界面无法正常工作,但在将视图向右或向左移动时,它仍保留为图像
如下图所示。
<?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>
【问题讨论】:
-
在父 Activity 中加载片段,而不是在您的 viewpager 中。
标签: java android horizontalscrollview