TextView
未显示最后一行半的文字。我正在使用ConstraintLayout
。在LinearLayout
它正在按预期工作。试过不同的方式,但它仍然认为它不会起作用。这是整个代码。
<?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:layout_height="match_parent"
android:background="#fff"
tools:context="com.welcomeshah.dictionary.MainActivity">
<LinearLayout
android:id="@+id/searchbarlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="5dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1"
android:background="@drawable/search_background"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="5dp">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginRight="5dp"
android:src="@drawable/searchline" />
<EditText
android:id="@+id/searchET"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@null"
android:hint="Type to search"
android:inputType="textPersonName"
android:textColor="#222" />
<ImageView
android:id="@+id/edit"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginLeft="5dp"
android:src="@drawable/backspace" />
</LinearLayout>
<ImageView
android:id="@+id/settings"
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@drawable/settings" />
</LinearLayout>
<View
android:id="@+id/shadow"
android:layout_width="match_parent"
android:layout_height="5dp"
android:background="@drawable/shadow_view"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/searchbarlayout" />
<TextView
android:id="@+id/data"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="fill"
android:background="#fff"
android:padding="5dp"
android:textSize="18sp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/shadow" />
<ListView
android:id="@+id/wordsList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffde00"
android:visibility="gone"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/shadow">
</ListView>
<LinearLayout
android:id="@+id/wait"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffde00"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Working on Databases"
android:textAlignment="center"
android:textSize="20sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Please wait for a few moments only for the first time."
android:textAlignment="center" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Thanks for you patience."
android:textAlignment="center" />
</LinearLayout>
</android.support.constraint.ConstraintLayout>
这是布局的图像。 {{3}}
还尝试添加android:includeFontPadding="false"
,但一切都是一样的。感谢你的努力。
答案 0 :(得分:0)
不建议对ConstraintLayout中包含的小部件使用MATCH_PARENT。可以通过使用MATCH_CONSTRAINT来定义类似的行为,其中相应的左/右或上/下约束被设置为“父”。
所以添加宽度为0dp 。请尝试下面的代码行。
<TextView
android:id="@+id/data"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#fff"
android:padding="5dp"
android:textSize="18sp"
android:layout_gravity="fill"
app:layout_constraintVertical_bias="0"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/shadow"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
答案 1 :(得分:0)
我在布局中显示了单个textview。
<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:id="@+id/activity_constraintset_example"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/textView11"
android:layout_width="0dp"
android:layout_height="0dp"
android:text="@string/lake_discription"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginTop="8dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="16dp"
tools:layout_constraintTop_creator="1"
tools:layout_constraintBottom_creator="1"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintVertical_bias="0.0" />
</android.support.constraint.ConstraintLayout>