Native

Native advertising is based on the user's own business layout and functions to build the layout, and then fill and display the advertising content in accordance with the native advertising rules so that the advertising and application style and elements can be adapted to achieve a seamless effect.

The current guide function shows how to use native ad controls and the rules and usage of related supporting templates.

Before you begin

You should finish the step of the Guide first.

Add the View in Layout

In the user layout, add a native advertising view and internal display controls, and the current components use basic TextView, ImageView and Video controls.

<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: united - current ad slot id, which is currently configured for native ad slots, users can fill in the XML page or set it after the interface controls are initialized, refer to the following.

Full example

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();
    }

}

Remark

Currently, native ads only support three elements: text, image, and video by default.

Last updated