AdFit-Native

  • adfit_native_ad_unit_layout.xml 샘플

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="3dp"
        android:gravity="center_vertical"
        android:orientation="horizontal">

        <ImageView
            android:id="@+id/adfit_profile_icon_view"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:contentDescription="AD Profile Icon"
            tools:src="@mipmap/ic_launcher" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="7dp"
            android:layout_marginRight="7dp"
            android:gravity="center_vertical"
            android:orientation="vertical">

            <TextView
                android:id="@+id/adfit_title_view"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textStyle="bold"
                tools:text="AD Title" />

            <TextView
                android:id="@+id/adfit_profile_name_view"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                tools:text="AD Profile Name" />
        </LinearLayout>
    </LinearLayout>

    <com.kakao.adfit.ads.na.AdFitMediaView
        android:id="@+id/adfit_media_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="3dp" />

    <TextView
        android:id="@+id/adfit_body_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="3dp"
        tools:text="AD Description" />

    <Button
        android:id="@+id/adfit_call_to_action_button"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        tools:text="AD Call To Action Button" />
</LinearLayout>

xml에서 생성한 ui component를 sdk에서 제공하는 setAdFitViewBinder API를 이용해 아래와 같이 설정해 줍니다.

AdFitViewBinder adFitViewBinder = new AdFitViewBinder.Builder(R.id.adFitNativeAdView, R.layout.adfit_native_ad_unit_layout)
        .titleViewId(R.id.adfit_title_view)
        .bodyViewId(R.id.adfit_body_view)
        .profileIconViewId(R.id.adfit_profile_icon_view)
        .profileNameViewId(R.id.adfit_profile_name_view)
        .callToActionButtonId(R.id.adfit_call_to_action_button)
        .mediaViewId(R.id.adfit_media_view)
				.testMode(false)
        .build();
adPopcornSSPNativeAd.setAdFitViewBinder(adFitViewBinder);

AdFitViewBinder Builder 생성 시, view id(R.id.adFitNativeAdView)layout id(R.layout.adfit_native_ad_unit_layout)는 필수로 넘겨주어야 하며, 그 외 ui component에 대해서는 사용하는 리소스에 대해서만 설정해 주면 됩니다.

테스트 광고 송출을 원할 경우, testModetrue 값을 전달하여 준다.

Last updated