当我在16:9手机上打开“活动”时,工具栏+列表视图会占用所有空间,没关系。
但是,当我在19:9的电话上打开它时,我的ListView(屏幕的1/5放大倍数)下方有一个空白。
此空白不是来自约束布局,因为它的白色和约束布局具有绿色背景颜色。
(下面我的活动的XML)
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="wrap_content"
android:background="@color/colorPrimaryLight"
tools:context=".MainActivity">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/colorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toTopOf="@id/mainListView"
android:minHeight="?android:attr/actionBarSize" >
</android.support.v7.widget.Toolbar>
<ListView
android:id="@+id/mainListView"
android:layout_width="match_parent"
android:layout_height="600dp"
android:background="@drawable/background7"
android:clipChildren="false"
android:clipToPadding="false"
android:divider="@android:color/transparent"
android:dividerHeight="10dp"
android:scrollbars="none"
app:layout_constraintTop_toBottomOf="@id/toolbar"
tools:context=".listview.MainActivity" />
</android.support.constraint.ConstraintLayout>
答案 0 :(得分:0)
尝试一下
class MyClass {
lateinit var foo: Any
fun doSomething() {
if (::foo.isInitialized) { // this is fine to use in Kotlin 1.2+
// Use foo
}
}
fun doSomethingElse() {
lateinit var bar: Any
if (::bar.isInitialized) { // this is currently unsupported (see link in Alexey's comment.
// Use bar
}
}
}