问题描述
我对android开发非常陌生,但除了启动应用程序外,还设法使我的应用程序正常工作。这是一个全屏应用程序,可连接到远程数据库并以横向或纵向显示此信息。以纵向启动时,即使连接数据库有问题,它也可以正常工作。当启动或切换到横向时,如果连接到数据库存在问题(通过connToDb.post(connToDbCode)可运行),则视图未完成,但在连接后最终看起来不错(其中使用另一个可运行的设备定期查询数据库)
我无法发布图像,所以...该视图显示带有渐变填充矩形背景的各个框,每个框内包含各种元素(文本,图像等)。视图/框未正确适合屏幕,并且背景渐变填充的矩形似乎是其原始大小(即未展开以填充框)。换句话说,视图无法正确完成绘制。在Android Studio中,以及在建立数据库连接之后,一切看起来都很好。
我不明白:
大型景观布局文件的开始:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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:id="@+id/mywxLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:keepScreenOn="true"
android:orientation="horizontal"
tools:context="mywx.FullscreenActivity">
<ImageView
android:id="@+id/tempBox"
android:layout_width="0dp"
android:layout_height="0dp"
android:contentDescription="@string/currentTemp"
android:background="@drawable/rec_bottom"
app:layout_constraintBottom_toTopOf="@+id/feelsLike"
app:layout_constraintEnd_toStartOf="@+id/windBox"
app:layout_constraintHorizontal_weight="5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_weight="7"
app:srcCompat="@drawable/rec_bottom" />
<ImageView
android:id="@+id/windBox"
android:layout_width="0dp"
android:layout_height="0dp"
android:contentDescription="@string/currentwind"
app:layout_constraintBottom_toBottomOf="@id/tempBox"
app:layout_constraintEnd_toStartOf="@+id/rainBox"
app:layout_constraintHorizontal_weight="5"
app:layout_constraintStart_toEndOf="@+id/tempBox"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/rec_top" />
我已经尽一切努力解决了这个问题,这个问题是在几个月前出现的(对库的更新还是其他问题?)。
我正在使用Android Studio V4.1.1,并且所有其他库都是截至2020年11月12日的最新信息。
解决方法
哇...发现了错误。默认文本字符串的其中一种翻译存在问题!修复了该问题,但随后不得不执行“文件/使缓存无效/重新启动...”
因此,最重要的是...如果显示不正常,请检查布局中Wrap_content文本项的Text值!