我正在阅读有关如何在您的应用程序上获取 adMob 的教程 Here和 在我的 Activity 的 xml 布局文件中,我遇到了渲染问题:
A <fragment> tag allows a layout file to dynamically include different layouts at runtime. At layout editing time the specific layout to be used is not known. You can choose which layout you would like previewed while editing the layout.
- <fragment xetron.cosmicclicker.MyActivity$AdFragment ...> (Pick Layout...)
- <fragment xetron.cosmicclicker.MyActivity$AdFragment ...> (Pick Layout...)
Do not warn about <fragment> tags in this session
下面 Activity 的 Xml 布局文件
<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:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="8dp"
android:orientation="vertical"
android:paddingBottom="6dp"
android:gravity="center|top"
android:background="@drawable/background"
tools:context=".MyActivity">
<fragment
android:name="xetron.cosmicclicker.MyActivity$AdFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/adFragment" />
<fragment
android:id="@+id/adFragment"
android:name="xetron.cosmicclicker.MyActivity$AdFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" />
</LinearLayout>
我做错了什么以及如何解决这个问题?
最佳答案
在您的 fragment 中尝试放入以下内容:
工具:布局=“@layout/my_fragment_view”
其中 my_fragment_view 是要加载到 fragment 中的布局。这仅供观众使用。我认为图形 View 给了你一个提示,以便它可以更流畅地渲染。工具属性仅适用于编辑器。在运行时不起作用。
<fragment
android:name="xetron.cosmicclicker.MyActivity$AdFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout="@layout/my_fragment_view"
android:layout_above="@+id/adFragment" />
关于java - admob 的 xml 呈现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26637740/