亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Android?App實現(xiàn)閃屏頁廣告圖的全屏顯示實例

 更新時間:2022年09月06日 11:14:57   作者:碧水逍遙  
這篇文章主要為大家介紹了Android?App實現(xiàn)閃屏頁廣告圖的全屏顯示實例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪

1. 適配長屏幕的全面屏

至于全屏展示,就得做適配工作,有以下兩種方式可進行適配:

  • 在 Android 8.0(API 26)及更高版本中,我們可以在 標簽中使用 android:MaxAspectRatio 來聲明其支持的屏幕最大寬高比。
  • 比如我們可以聲明最大寬高比為 2.4:
<!-- Render on full screen up to screen aspect ratio of 2.4 -->
<!-- Use a letterbox on screens larger than 2.4 -->
<activity android:maxAspectRatio="2.4">
 ...
</activity>
  • 對于Android 7.1及更低版本,我們可以在 元素中添加名為 android.max_aspect 的 元素

如下所示:

<!-- Render on full screen up to screen aspect ratio of 2.4 -->
<!-- Use a letterbox on screens larger than 2.4 -->
<meta-data android:name="android.max_aspect" android:value="2.4" />

2. 適配劉海屏或者水滴屏

Google 為劉海屏顯示方式提供了三種顯示模式:

// 默認情況,全屏頁面不可用劉海區(qū)域,非全屏頁面可以進行使用
public static final int LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT = 0;
// 允許頁面延伸到劉海區(qū)域
public static final int LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES = 1;
// 不允許使用劉海區(qū)域
public static final int LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER = 2;

凹形屏幕的顯示模式

我們可以通過下面兩種方式來指定應用在凹形屏幕的顯示模式:

  • 在主題中加入android:windowLayoutInDisplayCutoutMode 屬性指定顯示模式:
// value-v28/styles.xml
 <style name="AppTheme.Launcher" parent="AppTheme">
        <item name="android:windowBackground">@drawable/branded_launch_screens</item>
        <item name="android:statusBarColor">@color/colorPrimary</item>
        <item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
</style>
  • 通過在代碼中指定 Activity 的顯示模式

我們可以在 Activity 的 onCreate 中指定凹形屏幕的顯示模式:

@Override
protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (Build.VERSION.SDK_INT >= 28) {
            WindowManager.LayoutParams lp = getWindow().getAttributes();
            lp.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
            getWindow().setAttributes(lp);
        }
}

具體使用:需要在values-v27及以上的styles.xml中加入以下主題設置:

<!--實現(xiàn)啟動頁全屏-->
<style name="Theme.SplashActivity" parent="Theme.AppCompat.NoActionBar">
    <item name="android:windowBackground">@color/white</item>
    <item name="android:windowTranslucentStatus">false</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
    <item name="colorPrimary">@color/main_bg</item>
    <item name="colorPrimaryDark">@color/white</item>
    <item name="colorAccent">@color/white</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowTranslucentNavigation">true</item>
    <item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
</style>

以上就是Android App實現(xiàn)閃屏頁廣告圖的全屏顯示實例的詳細內(nèi)容,更多關于Android 閃屏頁廣告圖全屏的資料請關注腳本之家其它相關文章!

相關文章

最新評論