Java 滚动视图在其他内容下滚动
如何防止ScrollView在LinearLayout内容下查找内容? ScrollView只使用了所有的显示空间,我不能限制这一点。 与主要亲属和直系亲属一起尝试 我的代码:Java 滚动视图在其他内容下滚动,java,android,layout,scrollview,Java,Android,Layout,Scrollview,如何防止ScrollView在LinearLayout内容下查找内容? ScrollView只使用了所有的显示空间,我不能限制这一点。 与主要亲属和直系亲属一起尝试 我的代码: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" an
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" >
<LinearLayout
xmlns:myapp="http://schemas.android.com/apk/res/your.app.package"
android:id="@+id/ad_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
</LinearLayout>
<ScrollView
android:id="@+id/ScrollView1"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1" >
<RelativeLayout
android:id="@+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="bottom"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:contentDescription="@string/image"
android:onClick="openImage1"
android:scaleType="fitStart"
android:src="@drawable/loading"
android:adjustViewBounds="true"
android:background="#000000" />
</RelativeLayout>
</ScrollView>
</LinearLayout>
您还没有发布完整的XML代码;我只能猜测这些元素都包含在
线性布局
中,且具有垂直
方向
要获得滚动视图
以填充线性布局未占用的所有空间
,请使用布局权重
<ScrollView
android:id="@+id/ScrollView1"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1" >
我觉得你的scrollview中有一个RelativeLayout有点奇怪。。但是,如果我正确理解了您的问题,您希望滚动视图位于上面的线性布局下面。我猜您正在寻找以下内容:(看看我添加的新
线性布局
,以及下面的android:layout\u
。我还将外部布局更改为相对布局
;同样,我不确定您到底想做什么,但我希望这在某种程度上有所帮助。)
它包含在一个RelativeLayoutAh中,在这种情况下,您可能需要切换布局类型,因为您不希望两者重叠。您是否一直在使用RelativeLayout
?我现在将其更改为线性布局,但收到错误消息“LinearLayout:layout_centerHorizontal中的lyout参数无效”,与下面的布局相同,然后从滚动视图中删除这两个属性。无论如何,它应该自动位于ad_布局的下方。
你可以在我更新的第一篇文章中看到我的更改,但问题仍然存在。我给了小图像留了边距底部,在滚动视图中,默认线性布局有大数据,因此线性数据与图像重叠,对于更大的屏幕,这不是问题。对于小屏幕,这是一个问题(4英寸屏幕是一个问题)
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" >
<LinearLayout
xmlns:myapp="http://schemas.android.com/apk/res/your.app.package"
android:id="@+id/ad_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
</LinearLayout>
<LinearLayout
android:id="@+id/below_ad_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_below="@+id/ad_layout" >
<ScrollView
android:id="@+id/ScrollView1"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1" >
<RelativeLayout
android:id="@+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="bottom"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:contentDescription="@string/image"
android:onClick="openImage1"
android:scaleType="fitStart"
android:src="@drawable/loading"
android:adjustViewBounds="true"
android:background="#000000" />
</RelativeLayout>
</ScrollView>
</LinearLayout>
</RelativeLayout>