您好我想在整个屏幕上绘制ScrollView
,ScrollView
内容应该在整个屏幕上显示
但我也希望在屏幕底部显示我的广告。我在这里感到困惑,我只想给ScrollView
一个
高度类似(填充父级 - 20 px),我的广告应显示在屏幕底部的(20 PX)
请注意,滚动视图中的任何内容都应显示在整个屏幕上,但底部(20 px)除外。
答案 0 :(得分:2)
你可以试试这个:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="20dip"
android:id="@+id/adView"
android:layout_alignParentBottom="true"
>
</LinearLayout>
<ScrollView
android:layout_alignTop="@id/adView"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<!-- Page content -->
</ScrollView>
</RelativeLayout>
所以adView
将采用固定的20下降部分,其余部分将由ScrollView
采取。
希望这会有所帮助。
答案 1 :(得分:0)
使用此布局:
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:id="@+id/your_ad_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<Button
android:id="@+id/button"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:text="sample button" />
</LinearLayout>
<ScrollView
android:id="@+id/myscroll"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/your_ad_layout"
>
</>
</RelativeLayout>
答案 2 :(得分:0)
所有3个当前答案都使用RelativeLayout作为布局的根元素,这对性能不利。
使用FrameLayout代替,然后使ScrollView fill_parent - 20px,将其高度设置为fill_parent,将其layout_marginBottom设置为20px。将广告视图设置为layout_gravity =“bottom”,将其高度设置为20px。
此外,您应该将此20px 20dp,将其移动到值/ dimens.xml文件中,并将相同的值用于上述两个参数。然后很容易为每个屏幕尺寸/密度定义不同的尺寸。
答案 3 :(得分:0)
// try this
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="5dp"
android:orientation="vertical" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
</ScrollView>
<com.google.ads.AdView
android:id="@+id/adView1"
android:layout_width="match_parent"
android:layout_height="20dp"
app:adSize="SMART_BANNER"
app:adUnitId="ca-app-pub-9766031373541061/3761995838"
app:loadAdOnCreate="true"
app:testDevices="TEST_EMULATOR, TEST_DEVICE_ID" >
</com.google.ads.AdView>
</LinearLayout>