原生广告

原生广告是通过用户根据自身业务布局与功能进行构建布局后,配合原生广告规则进行广告内容填充和展示,做到广告与应用风格和元素适配,达到浑然一体的效果
当前指南功能展示原生广告控件使用方法以及相关配套模版使用规则与使用
前提
用户完成广告初始化步骤入门指南
布局中添加View
用户布局中,添加原生广告view与内部展示控件,当前组件采用基础TextView,ImageView与Video控件
<io.adx3.library.view.Adx3UserView
android:id="@+id/view_user"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:unitId="UnitId">
<ImageView
android:id="@+id/imageView"
android:layout_width="100dp"
android:layout_height="100dp"
android:scaleType="fitXY"
android:src="@mipmap/ic_launcher"
app:layout_constraintLeft_toLeftOf="parent" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:textColor="@color/black"
app:layout_constraintLeft_toRightOf="@+id/imageView" />
<io.adx3.library.view.videoplayer.player.Adx3VideoView
android:id="@+id/video_user"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_marginTop="10dp"
app:layout_constraintTop_toBottomOf="@+id/imageView" />
</io.adx3.library.view.Adx3UserView>
app:unitId - 当前广告位id,当前为原生广告位配置,用户可在xml页面填充或在界面控件初始化后设置,参考如下
若未在XML或代码中完成广告位配置填充,会导致广告加载失败,影响广告展示效果
完整控件使用示例
public class UserAInsertctivity extends AppCompatActivity {
TextView textView;
ImageView imageView;
Adx3UserView view_user;
Adx3VideoView video_user;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.xml);
initView();
setUserView();
}
private void initView() {
textView = findViewById(R.id.textView);
imageView = findViewById(R.id.imageView);
view_user = findViewById(R.id.view_user);
video_user = findViewById(R.id.video_user);
}
private void setUserView() {
//if you don't set the UnitId in XML
//view_user.setUnitId("UnitId");
view_user.setImageView(imageView);
view_user.setVideoView(video_user);
view_user.setTextView(textView);
view_user.load();
}
}
好了,到此,原生广告添加完成,执行load广告加载方法后,会自动填充广告到控件中,实现控件适配应用主题与风格
备注
当前原生广告默认仅支持文本,图片,视频三种元素
Last updated