👉 ダイアログ | Android デベロッパー | Android Developers


まともに書くと割と長いので、コピペ用にいまさら書いておく。
ダイアログの具の変更は、以下からコピペして、該当部分を書き換える。

👉 【Android】パパっと使えるAlertDialog一覧 - Qiita
しかし、公式リファレンスて、読むの疲れない?
間違ってはないけど、何かが変じゃない?
👉 ダイアログ | Android デベロッパー | Android Developers


まともに書くと割と長いので、コピペ用にいまさら書いておく。
ダイアログの具の変更は、以下からコピペして、該当部分を書き換える。

👉 【Android】パパっと使えるAlertDialog一覧 - Qiita
しかし、公式リファレンスて、読むの疲れない?
間違ってはないけど、何かが変じゃない?
スマートバナーてなくなるんですね!

全幅表示のバナーを引き続き使用したい場合は、以下のコード スニペットに示されるようにアダプティブ バナーを使用してください。
👉 SDK v20 の準備 | Android | Google Developers
サンプルコードのここら。
// Determine the screen width (less decorations) to use for the ad width.
// If the ad hasn't been laid out, default to the full screen width.
private val adSize: AdSize
get() {
val display = windowManager.defaultDisplay
val outMetrics = DisplayMetrics()
display.getMetrics(outMetrics)
val density = outMetrics.density
var adWidthPixels = ad_view_container.width.toFloat()
if (adWidthPixels == 0f) {
adWidthPixels = outMetrics.widthPixels.toFloat()
}
val adWidth = (adWidthPixels / density).toInt()
return AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(this, adWidth)
}
👉 アダプティブ バナー | Google Developers
コメントにも書かれてるけど、ほぼ無意味な
var adWidthPixels = ad_view_container.width.toFloat()
if (adWidthPixels == 0f) {
adWidthPixels = outMetrics.widthPixels.toFloat()
}
通常の利用するタイミングを考えるとほぼ常に「0f」 でしょうか。
他の公式サンプルを見てみます。
// Since we're loading the banner based on the adContainerView size, we need to wait until this
// view is laid out before we can get the width.
ad_view_container.viewTreeObserver.addOnGlobalLayoutListener {
if (!initialLayoutComplete) {
initialLayoutComplete = true
loadBanner()
}
}
👉 googleads-mobile-android-examples/MyActivity.kt
ad_view_container のレイアウトが完了するまで待ってから、loadBanner() → ad_view_container.width と処理が進んで前述分岐の意味が発生。
、、、
うん、
やっぱ、最近の公式サンプルコードやべーわ!
View サイズの取得のタイミングについては以下で🙆
👉 java - View's getWidth() and getHeight() returns 0 - Stack Overflow

以下は、Androidアプリ開発には、必ず使いますよね。
いや使うと良い、か。
👉 Maven Repository: org.jetbrains.kotlin » kotlin-bom
👉 Maven Repository: org.jetbrains.kotlinx » kotlinx-coroutines-bom
👉 Google's Maven Repository - BOM
👉 Maven Repository: com.squareup.okhttp3 » okhttp-bom
latest の更新に注意するためのな。
👉 bom - Google's Maven Repository
👉 org.jetbrains - Maven Central Repository Search