Android 在ListView中主布局上方和下方显示的广告
我想在展示区的底部展示一个图片广告。我试过使用底部,但不起作用。你能帮我吗Android 在ListView中主布局上方和下方显示的广告,android,android-linearlayout,adview,Android,Android Linearlayout,Adview,我想在展示区的底部展示一个图片广告。我试过使用底部,但不起作用。你能帮我吗 MainActivity.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:orientation="ve
MainActivity.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent"
tools:context=".MainActivity">
<include
android:id="@+id/tool_bar"
layout="@layout/tool_bar"
></include>
<LinearLayout
android:id="@+id/adLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="center_horizontal"
android:orientation="horizontal"></LinearLayout>
<ListView
android:id="@+id/ilcelerListview"
android:layout_width="match_parent"
android:layout_height="wrap_content"></ListView>
</LinearLayout>
MainActivity.xml
图片链接:我可以给你两个建议 您可以在MainActivity中使用RelativeLayout而不是LinearLayout 为此,您可以轻松地添加要添加到底部的视图 或 LayoutParams params=新的LayoutParams( ViewGroup.LayoutParams.WRAP_内容,ViewGroup.LayoutParams.MATCH_父项) //可以使用参数在底部或其他位置进行设置 //景色属于你
rootView.addView(view, params);
更正语法和措辞。
rootView.addView(view, params);