【问题标题】:LinearLayout after setting Visibility of Ads to Visible the View is being cropped将广告的可见性设置为可见后的 LinearLayout 正在裁剪视图
【发布时间】:2015-01-09 13:00:11
【问题描述】:

我在我的应用中使用以下布局:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/frame"
        android:layout_height="match_parent"
        android:layout_width="match_parent">
    <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_height="match_parent"
        android:layout_width="match_parent" />
    <LinearLayout
        android:id="@+id/id1"
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:orientation="vertical">
            <LinearLayout
                android:id="@+id/container"
                android:layout_height="250dp"
                android:layout_width="match_parent"
                android:orientation="vertical">
                   <FrameLayout
                     android:id="@+id/id2"
                     android:layout_height="200dp"
                     android:layout_width="match_parent"
                     android:background="@color/white" />
                   <pagerslidingtabstrip.PagerSlidingTabStrip
                      android:id="@+id/tabs"
                      android:layout_width="match_parent"
                      android:layout_height="@dimen/pagertagstrip_height" 
                      android:background="@android:color/transparent" />
            </LinearLayout>
            <LinearLayout
               android:id="@+id/ads"
               android:layout_height="wrap_content"
               android:layout_width="match_parent"
               android:visibility="gone" />
    </LinearLayout>
</FrameLayout>

编辑: 在 id2 的 FrameLayout 中,我正在插入另一个视图寻呼机。 id Pager 的寻呼机由 pagerslidingtabstrip 控制,包含 4 个 ListView。我还实现了视差标头示例的一部分。因此,滚动 Listviews 会改变具有 id = id1 的 LinearLayout 的翻译。

问题是,在我在横向模式下启用广告(将可见性设置为 Visible 并在 LinearLayout 中插入 id = ads 的视图)后,部分广告不适合屏幕。但是,如果我滚动查看广告,则会裁剪广告的视图。屏幕外的部分没有被渲染,我只能看到广告视图的一部分。我该如何解决这个问题?

我收到的广告类似于上面的示例图片(红色只是来自背景)

【问题讨论】:

  • 我不明白为什么要创建这种类型的视图层次结构。为什么你需要 LinearLayout 来展示广告。它们必须是您的广告提供商 SDK 中的 View 类。你在使用 admob 吗?
  • 我正在使用自定义广告提供商 Sdk,并且指南说使用 LinearLayout 作为广告(视图)的父级。我不认为问题出在 LinearLayout。
  • 请发布完整的 xml...
  • 我发布了完整的 xml 并添加了有关用例的说明。我不认为这会以某种方式影响我的问题。我认为在广告设置为可见后框架布局没有改变它们的高度一定是个问题
  • 检查我编辑的答案...

标签: android android-layout view android-linearlayout


【解决方案1】:

试试这个

添加layout_gravity="center_horizontal你的父母framelayout

 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/frame"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center_horizontal" >

希望有效果

【讨论】:

  • 这不起作用。 Viewpager 现在没有显示任何内容,在横向模式下我也看不到广告视图
  • 感谢您的宝贵时间。但可悲的是,这似乎并没有解决我的问题。我认为这是android内部的东西,它可以调整框架布局的大小。系统只让它在第一次渲染时保持原样
猜你喜欢
  • 1970-01-01
  • 2016-10-24
  • 1970-01-01
  • 2021-10-16
  • 2017-05-24
  • 2012-11-09
  • 1970-01-01
  • 2013-06-11
  • 2016-02-27
相关资源
最近更新 更多