android - 一种布局在约束布局中与整个屏幕重叠,目前只有一台设备 OnePlus 5
问题描述
我做了以下布局:
使用带有 NestedScrollView 的 LinearLayout 和子 ConstraintLayout。 问题:布局在几乎所有设备上都运行良好,但问题似乎是分辨率为 1080*1920 的 Oneplus 5。这是布局xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
android:orientation="vertical">
<include layout="@layout/toolbar_with_filter_back" />
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:fillViewport = "true"
android:layout_height="match_parent">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:src="@drawable/banner"
app:layout_constraintTop_toTopOf="parent"
tools:layout_editor_absoluteX="0dp" />
<android.support.constraint.Guideline
android:id="@+id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_begin="165dp" />
<android.support.v7.widget.CardView
android:id="@+id/win_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/_5sdp"
android:elevation="@dimen/_8sdp"
app:cardCornerRadius="@dimen/_10sdp"
app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="true"
app:layout_constraintTop_toBottomOf="@+id/guideline">
<LinearLayout
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:orientation="horizontal"
android:padding="@dimen/_10sdp">
<android.support.v7.widget.CardView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.4"
android:gravity="center"
android:scaleType="fitXY"
app:cardCornerRadius="8dp"
app:cardPreventCornerOverlap="true">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/exec_business_icon"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="center"
android:scaleType="fitXY"
android:src="@drawable/icon_dairy" />
<TextView
android:id="@+id/exec_business_iconname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@color/exec_card_second_title"
android:fontFamily="@font/boutrosasma_regular"
android:gravity="center"
android:text="Foods"
android:textColor="@color/white"
android:textSize="@dimen/text_size_h" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center">
<TextView
android:id="@+id/tvRname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:ellipsize="end"
android:fontFamily="@font/boutrosasma_bold"
android:gravity="center"
android:text="@string/exe_size"
android:textColor="@color/exec_card_second_title"
android:textSize="@dimen/text_size_h_valve"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="@+id/fb_sr_bu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:ellipsize="end"
android:fontFamily="@font/boutrosasma_regular"
android:gravity="center"
android:text="SR"
android:textColor="@color/exec_card_size_val_color"
android:textSize="@dimen/text_size_h"
android:textStyle="bold" />
<TextView
android:id="@+id/fb_size_val_bu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/_5sdp"
android:ellipsize="end"
android:fontFamily="@font/boutrosasma_bold"
android:gravity="center"
android:text="56.9"
android:maxLength="5"
android:textColor="@color/exec_card_size_val_color"
android:textSize="@dimen/_14ssp"
android:textStyle="bold" />
<TextView
android:id="@+id/fb_bn_bu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:ellipsize="end"
android:fontFamily="@font/boutrosasma_regular"
android:gravity="center"
android:text="BN"
android:layout_marginLeft="@dimen/_5sdp"
android:textColor="@color/exec_card_size_val_color"
android:textSize="@dimen/text_size_h"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="@drawable/layer_5" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center">
<TextView
android:id="@+id/tvgrowth"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:ellipsize="end"
android:fontFamily="@font/boutrosasma_bold"
android:gravity="center"
android:text="@string/exe_growth"
android:textColor="@color/exec_card_second_title"
android:textSize="@dimen/text_size_h_valve"
android:textStyle="bold" />
</LinearLayout>
<TextView
android:id="@+id/fb_growth_bu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:ellipsize="end"
android:fontFamily="@font/boutrosasma_bold"
android:gravity="center"
android:text="+7.0%"
android:maxLength="6"
android:textColor="@color/exec_growth_val_color"
android:textSize="@dimen/_14ssp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="@+id/card_topplayer"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_margin="@dimen/_5sdp"
android:elevation="@dimen/_8sdp"
app:cardCornerRadius="@dimen/_10sdp"
app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="true"
app:layout_constraintTop_toBottomOf="@+id/win_card"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/top_player_back"
android:padding="@dimen/_10sdp">
<TextView
android:id="@+id/top_player"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/boutrosasma_bold"
android:text="@string/business_unit_top"
android:textColor="@color/exec_card_size_val_color" />
<ImageView
android:id="@+id/orientation_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:src="@drawable/orientation" />
</RelativeLayout>
<com.github.mikephil.charting.charts.LineChart
android:layout_margin="@dimen/_5sdp"
android:layout_width="match_parent"
android:layout_height="@dimen/_200sdp"
android:id="@+id/business_lineChart"/>
<View
android:layout_margin="@dimen/_5sdp"
android:layout_width="match_parent"
android:layout_height="2dp"
android:alpha="0.2"
android:background="@color/horizontal_line"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/legendRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="@dimen/_10sdp"/>
</LinearLayout>
</android.support.v7.widget.CardView>
</android.support.constraint.ConstraintLayout>
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
测试:
- 尝试使用 Oreo/ Pie 设备
- 创建了一个运行 oreo 8.1 的具有相同分辨率的模拟器
我还无法重新生成问题。Oneplus5 屏幕是我从评论中收到的:
请建议我是否应该对布局进行任何更改。我正在考虑的一个想法是不使用约束布局并使用线性或相对而不是那样,但主要问题是设置第一个与该背景图像具有相同对齐的卡片视图,因为该背景瓶图像甚至没有覆盖一半屏幕,所以我 center_vertical 不适用于第一个卡片视图的所有屏幕尺寸。请给一些建议。
解决方案
推荐阅读
- named-entity-recognition - 对于迁移学习的 spacy NER 模型上未见的自定义实体实例,召回率和 f1 分数非常低(~0.55 和 0.65)
- sql - SQL:使用 regexp_substr ot regexp_extract,寻找只返回一个字符和一个空格之间的字符串的正则表达式模式
- java - 找不到 apache poi 库
- javascript - 带有随机数据问题的时间序列的 Javascript 实时图表
- javascript - 为什么 input[type='tel'] 允许输入非数字字符?
- api - 如何使用 Blogger API 将我的帖子划分为不同的 FeedActivity?
- python - Python动态递增数字
- c++ - 使用 g++ 编译的 C++ 代码有效,但 XCode 失败
- c - 在 HP Tandem 上将数据从 C 发送到 COBOL
- jquery - 来自 WordPress 的 jQuery 版本不适用于我的函数,我无法更改 jQuery 版本