gpt4 book ai didi

android - 在 android 的 ScrollView 底部添加填充?

转载 作者:行者123 更新时间:2023-11-30 03:48:22 25 4
gpt4 key购买 nike

我想在此 ScrollView 的底部添加填充,因为文本与底部的广告重叠。我是 android 开发人员的新手。我查看了其他几个帖子,但似乎无法弄清楚我的问题。谢谢!

这是我的 weddingfragment.xml

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="false"
android:gravity="center"
android:scrollbars="horizontal" android:id="@+id/ScrollView">

<LinearLayout
android:layout_width="fill_parent"
android:orientation="vertical"
android:id="@+id/linearLayout2"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal">

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Formal or Black Tie"
android:layout_marginTop="16dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" • This means you should wear a Tuxedo or a dark colored suit."
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
</ScrollView>

这是我的 activity_main.xml,它是 weddingfragment.xml 的父级

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<com.google.ads.AdView android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId=""
ads:adSize="BANNER"
ads:testDevices=""
ads:loadAdOnCreate="true"
android:layout_alignParentBottom="true" />
</RelativeLayout>

最佳答案

正如我在评论中所说,这是一个 XML 示例,您可以使用它来对 fragment 进行运行时更改,并且仍然有您的 adview:

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"

<!-- Get a reference to this fragment and use the fragment .commit() to change it. See the API guides for more info. It must be a framelayout or you can't edit it. -->
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/frag_wedding_container"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</FrameLayout>

<com.google.ads.AdView android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId=""
ads:adSize="BANNER"
ads:testDevices=""
ads:loadAdOnCreate="true"
android:layout_alignParentBottom="true" />

</LinearLayout>

关于android - 在 android 的 ScrollView 底部添加填充?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14574817/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com