Help Center/Details/

Template Draw Video Ads


Template rendering Draw: Developers do not need to edit and render the ad style by themselves, they can directly call the relevant interface to get the ad view for display

Supported ad size: vertical video (aspect ratio 16:9)

Note: Developers are not supported to add buttons to the view and block ads


**Template rendering Draw video ads: ** Provided by default

Template rendering information flow request method (TTNativeExpressAd)

Note: The template ad request method requires the developer to set the setExpressViewAcceptedSize parameter in dp.
If the height is set to 0, the returned view will be highly adaptive according to the different templates checked on the platform.

Create TTAdNative object

//创建TTAdNative对象,createAdNative(Context context) context需要传入Activity对象
TTAdNative mTTAdNative = TTAdSdk.getAdManager().createAdNative(this);

Create ad request AdSlot

AdSlot adSlot = new AdSlot.Builder()
        .setCodeId(codeId) //广告位id
        .setAdCount(1) //请求广告数量为1到3条
        .setExpressViewAcceptedSize(expressViewWidth,expressViewHeight) //期望模板广告view的size,单位dp

Parameter description

Parameter description
setCodeId The code ID created by the platform starts with 9 and 9 digits
setAdCount The number of requests is 1-3. It is recommended to set to 1
setExpressViewAcceptedSize Set the size of the request template creative unit: dp

Note: In the parameter setting of the desired personalized template size, the personalized template Draw video ad height cannot be set to 0

Request ads

The access party can call loadExpressDrawFeedAd(AdSlot adSlot, @NonNull NativeExpressAdListener listener) to load ads asynchronously
Note: The click event registration time is before the ad render, otherwise it will affect the display and click data reporting

mTTAdNative.loadExpressDrawFeedAd(adSlot, new TTAdNative.NativeExpressAdListener() {
    public void onError(int code, String message) {
    public void onNativeExpressAdLoad(List<TTNativeExpressAd> ads) {

NativeExpressAdListener Description

Callback Description
onError() Advertisement request failed callback The returned error code (code) indicates the reason why the advertisement request failed,详情请见链接
onNativeExpressAdLoad() Callback for successful ad request, the client can call render() in this callback for ad rendering

Ad click event listener

ad.setExpressInteractionListener(new TTNativeExpressAd.ExpressAdInteractionListener() {
       public void onAdClicked(View view, int type) {

       public void onAdShow(View view, int type) {

       public void onRenderFail(View view, String msg, int code) {

       public void onRenderSuccess(View view, float width, float height) {

ExpressAdInteractionListener Description

Callback Description
onAdClicked() The callback of the ad click, the action after the click is controlled by the sdk.
onAdShow() Advertisement display callback, display volume can be counted in the method provided by CSJ
onRenderFail() Personalized template rendering failed
onRenderSuccess() The personalized template is rendered successfully, the client can directly add the view of the advertisement to the control to be displayed in the callback

Note: After loading the ad, call the TTNativeExpressAd.render() method to render the ad. In the onRenderSuccess(View view, float width, float height) callback, handle the logic of adding the ad view, width&height is The width and height of the ad.


* 设置视频广告的回调监听
ad.setVideoAdListener(new TTNativeExpressAd.ExpressVideoAdListener() {
    public void onVideoLoad() {

    public void onVideoError(int errorCode, int extraCode) {

    public void onVideoAdStartPlay() {

    public void onVideoAdPaused() {

    public void onVideoAdContinuePlay() {

    public void onProgressUpdate(long current, long duration) {

    public void onVideoAdComplete() {

    public void onClickRetry() {


ExpressVideoAdListener description

Method Description
onVideoLoad() Video ad loaded successfully callback
onVideoError() Video ad loading failed callback
onVideoAdStartPlay() Video ad show callback
onVideoAdPaused() Video ad pause callback
onVideoAdContinuePlay() Video ad rebroadcast callback
onProgressUpdate() Video ad playback progress callback
onVideoAdComplete() Video ad playback complete callback
onClickRetry() Video ad click replay callback

Destroy the ad object

protected void onDestroy() {
    if (mTTAd != null) {

Reference Demo

For template Draw ads, please refer to the DrawNativeExpressVideoActivity example in Demo

Template rendering Draw Note:

  1. The personalized template Draw ad does not support dislike logic.
  2. In the parameter setting of the template size, the height of the personalized template Draw video advertisement cannot be set to 0
Did the content solve your problem?
Contact us