【问题标题】:Bottom navigation bar hides part of a view底部导航栏隐藏视图的一部分
【发布时间】:2017-03-22 13:02:15
【问题描述】:

在我的应用程序中,我想显示一个简单的图像,

在我的三星 Galaxy S7 Real 设备上,图像很好,底部导航栏不是视图的一部分,而是手机本身的一部分。 整个图像都存在。

在 Android 模拟器上,底部导航栏是视图的一部分,图像部分隐藏

这是我的简单线性布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout         
    xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:fitsSystemWindows="true"
          android:background="@color/md_blue_50"
          android:orientation="vertical">

    <include
        android:id="@+id/app_bar"
        layout="@layout/toolbar"/>

    <ImageView
        android:id="@+id/photo_image_large"
        android:adjustViewBounds="true"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="fill_vertical"
        android:scaleType="fitXY"/>

</LinearLayout>

这是安卓模拟器截图

android emulator

这是我的三星 Galaxy 真机屏幕截图

android real device

问题也出现在应用中的recycler Views android模拟器上图片的底部被截断...

【问题讨论】:

    标签: android


    【解决方案1】:

    因为android:fitSystemWindows把它设置为false应该是好的

    【讨论】:

      【解决方案2】:

      BottomNavigationView(菜单)有类似的问题,这是解决方案:

      <LinearLayout
          xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:app="http://schemas.android.com/apk/res-auto"
          android:id="@+id/main_activity_main_layout"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:orientation="vertical">
      
      <FrameLayout
          android:id="@+id/main_activity_container"
          android:layout_width="match_parent"
          android:layout_height="0dp"
          android:layout_weight="1">  
      </FrameLayout>
      
      
      <android.support.design.widget.BottomNavigationView
          android:id="@+id/navigation"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_gravity="start"
          app:itemIconTint="@color/color_main_white"
          app:itemTextColor="@color/color_main_white"
          app:menu="@menu/bottom_navigation_menu"/> 
      

      尝试将参数 android:layout_heigh 更改为 0dp 并为 ImageView 添加这个 android:layout_weight="1"

      【讨论】:

        【解决方案3】:

        您必须将视图放在底部导航栏上方,以便视图不会隐藏在底部导航栏中

        【讨论】:

        • 但是底部导航栏甚至不是视图的一部分——请参考我的LinearLayout...
        • 是的,我理解它是一个 android 模拟器它不是真正的设备,所以当你将应用程序放入 Play 商店时没有问题
        • 刚试了android:fitsSystemWindows="false" 图像还是一样
        • 你可以把屏幕截图贴出来
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-07-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-01-13
        • 1970-01-01
        相关资源
        最近更新 更多