简体   繁体   English

如何使视图覆盖整个屏幕?

[英]How to make the View to cover the whole screen?

I have a View which should cover the whole screen. 我有一个应该覆盖整个屏幕的视图。 But the problem is that it doesn't cover ToolBar. 但是问题在于它不包含ToolBar。 I tried simply View, I also tried ImageView with setScaleType(ScaleType.FIT_XY) . 我只是尝试查看,我也尝试了setScaleType(ScaleType.FIT_XY) ImageView I can't figure out how to do it. 我不知道该怎么做。

I need it to make my activity look inactive. 我需要它使我的活动看起来不活跃。 Like on this screenshot: 像此屏幕截图所示: 在此处输入图片说明

My layout: 我的布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  tools:context=".activity.MainActivity">

  <View
    android:id="@+id/transparent_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:alpha="20"
    android:background="@color/darkGrey"
    android:visibility="gone">
  </View>

  <android.support.v7.widget.Toolbar
    android:id="@+id/toolbar_main"
    android:layout_width="match_parent"
    android:layout_height="80dp"
    android:layout_alignParentTop="true"
    android:background="?attr/colorPrimary"
    android:elevation="4dp"
    android:minHeight="?attr/actionBarSize"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
    app:title="Your Wi-Fi is online">

    <Button
      android:id="@+id/btn_pause"
      android:layout_width="90dp"
      android:layout_height="36dp"
      android:layout_margin="17dp"
      android:layout_gravity="end"
      android:background="@color/white"
      android:text="@string/pause"
      android:textColor="@color/midPurple"
      android:textSize="14sp" />
  </android.support.v7.widget.Toolbar>

  <android.support.design.widget.TabLayout
    android:id="@+id/tabs"
    style="@style/AppTabLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/toolbar_main"
    android:background="?attr/colorPrimary"
    android:elevation="4dp"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />

  <android.support.v4.view.ViewPager
    android:id="@+id/viewpager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/tabs" />

</RelativeLayout>

If i'm correct understand you, you want to have full screen view? 如果我正确理解您的意思,您想拥有全屏视图吗? https://developer.android.com/training/system-ui/immersive.html https://developer.android.com/training/system-ui/immersive.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我希望文本视图能覆盖整个屏幕 - I want text view to cover whole Screen 尽管屏幕不同,如何使视图覆盖屏幕 - How to make a view to cover your screen despite different screens 如果 ImageView 包含在不覆盖整个屏幕的 ViewPager 的片段中,是否可以使 ImageView 覆盖整个屏幕? - Is it possible to make an ImageView cover the whole screen, if it's contained in a fragment in a ViewPager that doesn't cover the whole screen? 如何创建一个不能覆盖整个屏幕的片段 - How to create a fragment that does not cover the whole screen 如何创建可响应的GridView以覆盖整个屏幕? - How to create responsive GridView to cover whole screen? 除了某些元素,如何通过透明视图(alpha为80%)覆盖整个屏幕? - How to cover the whole screen by transparent view (alpha 80%), except for some elements? 如何在 Jetpack Compose 中使底片覆盖整个屏幕 - How do I make Bottom Sheet cover whole screen in Jetpack Compose 如何让闪屏图像覆盖屏幕? - How to make splash screen image cover the screen? 约束布局-如何使图像视图(框架)在整个屏幕上移动 - Constraint Layout - How to make an image view (frame) to move on whole screen 如何使软输入覆盖屏幕底部? - How to make softinput cover the screen bottom?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM