我在线性布局中创建了一个滚动视图。在23 api或以上工作正常,但在api下面,屏幕不起作用,也不会抛出任何异常。我在fragment中使用了这个scrollview。我在recyclerview中也遇到了同样的问题。是否有任何支持的库问题或其他问题。
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_marginTop="@dimen/_2sdp"
android:weightSum="10"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="@dimen/_130sdp">
<LinearLayout
android:layout_weight="4.9"
android:layout_width="0dp"
android:layout_height="match_parent">
<Button
android:id="@+id/underwaterpark"
android:background="@drawable/underwatertunnel"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:layout_weight="0.2"
android:layout_width="0dp"
android:layout_height="match_parent"></LinearLayout>
<LinearLayout
android:layout_weight="4.9"
android:layout_width="0dp"
android:layout_height="match_parent">
<Button
android:id="@+id/aquadam"
android:background="@drawable/aqua_dam"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_marginTop="@dimen/_3sdp"
android:weightSum="10"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="@dimen/_130sdp">
<LinearLayout
android:layout_weight="4.9"
android:layout_width="0dp"
android:layout_height="match_parent">
<Button
android:id="@+id/suites"
android:background="@drawable/deluxsuite"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:layout_weight="0.2"
android:layout_width="0dp"
android:layout_height="match_parent"></LinearLayout>
<LinearLayout
android:layout_weight="4.9"
android:layout_width="0dp"
android:layout_height="match_parent">
<Button
android:id="@+id/marine"
android:background="@drawable/marinethemedresturant"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_marginTop="@dimen/_3sdp"
android:weightSum="10"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="@dimen/_130sdp">
<LinearLayout
android:layout_weight="4.9"
android:layout_width="0dp"
android:layout_height="match_parent">
<Button
android:id="@+id/pool"
android:background="@drawable/infinitypool"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:layout_weight="0.2"
android:layout_width="0dp"
android:layout_height="match_parent"></LinearLayout>
<LinearLayout
android:layout_weight="4.9"
android:layout_width="0dp"
android:layout_height="match_parent">
<Button
android:id="@+id/waterpark"
android:background="@drawable/indoorwaterpark"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_marginTop="@dimen/_3sdp"
android:layout_marginBottom="@dimen/_2sdp"
android:weightSum="10"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="@dimen/_130sdp">
<LinearLayout
android:layout_weight="4.9"
android:layout_width="0dp"
android:layout_height="match_parent">
<Button
android:id="@+id/apartments"
android:background="@drawable/apartmentswithlawn"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:layout_weight="0.2"
android:layout_width="0dp"
android:layout_height="match_parent"></LinearLayout>
<LinearLayout
android:layout_weight="4.9"
android:layout_width="0dp"
android:layout_height="match_parent">
<Button
android:id="@+id/helipad"
android:background="@drawable/ehelipad"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
答案 0 :(得分:0)
我已经更新了此XML代码,请尝试:
config.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
答案 1 :(得分:0)
试试这个,
android:fillViewport="true"
例如:
<ScrollView
android:layout_width="match_parent"
android:fillViewport="true"
android:layout_height="wrap_content">
</ScrollView>
它可能对你有所帮助。
答案 2 :(得分:0)
Ypu正在使用已弃用的fill_parent
现在您应该使用match_parent
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
将其更改为
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true" // you can add this line too but it should work without it
>