这是我的XML代码
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.techdrive.hindimovietrailers.DetailsActivity"
tools:showIn="@layout/activity_details">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent">
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:cardview="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:id="@+id/card1"
cardview:cardCornerRadius="5dp"
cardview:cardBackgroundColor="@android:color/white"
cardview:cardElevation="4dp"
android:foreground="?android:attr/selectableItemBackground"
cardview:cardUseCompatPadding="true"
android:layout_height="230dp"
android:layout_margin="@dimen/margine_card">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="200dp">
<ImageView
android:layout_width="170dp"
android:layout_height="180dp"
android:id="@+id/image_url"
android:background="@mipmap/ic_launcher"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Title"
android:maxLines="2"
android:layout_toRightOf="@+id/image_url"
android:id="@+id/title_movie"
android:layout_alignParentTop="true"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Released Date:"
android:paddingBottom="10dp"
android:id="@+id/released_date"
android:layout_toRightOf="@+id/image_url"
android:layout_below="@+id/title_movie"
android:layout_alignLeft="@+id/title_movie"
android:layout_alignStart="@+id/title_movie" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Date"
android:maxLines="2"
android:id="@+id/date_movie"
android:layout_below="@+id/released_date"
android:layout_toRightOf="@+id/image_url"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Genery:"
android:id="@+id/genery"
android:layout_below="@+id/date_movie"
android:layout_alignParentRight="true"
android:layout_toRightOf="@+id/image_url"
android:layout_alignParentEnd="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Genery Description"
android:id="@+id/genery_movie"
android:layout_below="@+id/genery"
android:layout_toRightOf="@+id/image_url"
android:layout_toEndOf="@+id/image_url" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Rating:"
android:id="@+id/rating"
android:layout_below="@+id/genery_movie"
android:layout_toRightOf="@+id/image_url"
android:layout_toEndOf="@+id/image_url" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="rating"
android:id="@+id/rating_movie"
android:layout_alignTop="@+id/rating"
android:layout_toRightOf="@+id/rating"
android:layout_toEndOf="@+id/rating" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:cardview="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_below="@+id/card1"
android:id="@+id/card2"
cardview:cardCornerRadius="5dp"
cardview:cardBackgroundColor="@android:color/white"
cardview:cardElevation="4dp"
android:foreground="?android:attr/selectableItemBackground"
cardview:cardUseCompatPadding="true"
android:layout_height="180dp"
android:layout_margin="@dimen/margine_card">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="180dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Details:"
android:id="@+id/details_movie"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Run Time:"
android:id="@+id/runtime"
android:layout_below="@+id/details_movie"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="run"
android:id="@+id/run_movie"
android:layout_below="@+id/details_movie"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Region:"
android:id="@+id/textView"
android:layout_below="@+id/runtime"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="region"
android:id="@+id/region_movie"
android:layout_alignTop="@+id/textView"
android:layout_alignRight="@+id/run_movie"
android:layout_alignEnd="@+id/run_movie" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Bufget:"
android:id="@+id/budget"
android:layout_below="@+id/textView"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="budget"
android:id="@+id/budget_movie"
android:layout_below="@+id/region_movie"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Revenue:"
android:id="@+id/revenue"
android:layout_below="@+id/budget"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="revenue"
android:id="@+id/revenue_movie"
android:layout_alignTop="@+id/revenue"
android:layout_alignRight="@+id/run_movie"
android:layout_alignEnd="@+id/run_movie" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Country:"
android:id="@+id/country"
android:layout_below="@+id/revenue"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="country"
android:id="@+id/country_movie"
android:layout_below="@+id/revenue_movie"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<include layout="@layout/sum_content" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="SMART_BANNER"
ads:adUnitId="ca-app-pub-9538253184459093/3329616766" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
当我运行我的应用程序时,我的广告没有显示。我正在使用LinearLayout
和RelativeLayout
来整理我的布局。
所以我把我的adview xml放在哪里展示它。
我希望在屏幕下方显示广告。因此,用户可以轻松滚动屏幕上的所有元素,广告就能完美呈现。