[英]Layout nesting problems in Android
我有一個scrollview滾動時表現得很奇怪。 在滾動視圖開始滾動之前,我必須滾動兩次。 下面是我完成嵌套的方式。 這個嵌套看起來不錯還是不好? 我嘗試重新排列布局,但無法停止遇到的“兩次”滾動問題。
第一個布局:(此布局位於約束布局內)
//views before
<ScrollView
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toTopOf="@+id/yahoo_view"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/cond_const"
android:id="@+id/scrollView2"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include
layout="@layout/scroll_content"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</ScrollView>
//views after
第二布局:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:custom="http://schemas.android.com/tools"
android:id="@+id/scrollview3">
<android.support.constraint.ConstraintLayout
android:id="@+id/forecast_constraint"
android:layout_width="match_parent"
android:layout_height="wrap_content">
//all this layout-files views here
</android.support.constraint.ConstraintLayout>
</ScrollView>
編輯:
也許我誤會了,但是您希望屏幕在兩個方向上滾動嗎?
如果不是,則不要在滾動視圖內嵌套滾動視圖。
兩者都可能已過時。 現在刪除您的。
嘗試一下
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:custom="http://schemas.android.com/tools"
android:id="@+id/scrollview">
<android.support.constraint.ConstraintLayout
android:id="@+id/forecast_constraint"
android:layout_width="match_parent"
android:layout_height="wrap_content">
//all this layout-files views here
</android.support.constraint.ConstraintLayout>
</ScrollView>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.