我有以下布局,我的问题是TextView
只显示3行,甚至更长的文字也没有。
请问我的错误是什么?
<?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="wrap_content">
<FrameLayout
android:id="@+id/frameLayout"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/btStartItem"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ProgressBar
android:id="@+id/pbTestItem"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="0dp"
android:paddingStart="?android:attr/expandableListPreferredItemPaddingLeft"
android:progressBackgroundTint="@android:color/transparent"
android:progressTint="@android:color/holo_orange_light"
android:scaleY="5"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:visibility="visible" />
<TextView
android:id="@+id/lblListItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="fill"
android:clickable="true"
android:gravity="left"
android:paddingStart="?android:attr/expandableListPreferredItemPaddingLeft"
android:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</FrameLayout>
<Button
android:id="@+id/btStartItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:text="@string/action_start"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/ivStatusItem"
app:layout_constraintStart_toEndOf="@+id/frameLayout"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/ivStatusItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:adjustViewBounds="true"
android:contentDescription="@string/status_test"
android:cropToPadding="false"
android:maxHeight="40dp"
android:maxWidth="40dp"
android:src="@drawable/question"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/btStartItem"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
答案 0 :(得分:1)
尝试以下方法:
<?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="wrap_content">
<FrameLayout
android:id="@+id/frameLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/btStartItem"
android:adjustViewBounds="true"
app:layout_constraintHorizontal_weight="40"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ProgressBar
android:id="@+id/pbTestItem"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:paddingStart="?android:attr/expandableListPreferredItemPaddingLeft"
android:progressBackgroundTint="@android:color/transparent"
android:progressTint="@android:color/holo_orange_light"
android:scaleY="5"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:visibility="visible" />
<TextView
android:id="@+id/lblListItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="fill"
android:clickable="true"
android:gravity="left"
android:paddingStart="?android:attr/expandableListPreferredItemPaddingLeft"
android:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."
app:layout_constraintBottom_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</FrameLayout>
<Button
android:id="@+id/btStartItem"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:text="@string/action_start"
android:visibility="visible"
android:adjustViewBounds="true"
app:layout_constraintHorizontal_weight="30"
app:layout_constraintEnd_toStartOf="@+id/ivStatusItem"
app:layout_constraintStart_toEndOf="@+id/frameLayout"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/ivStatusItem"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:adjustViewBounds="true"
app:layout_constraintHorizontal_weight="30"
android:cropToPadding="false"
android:maxHeight="40dp"
android:maxWidth="40dp"
android:src="@drawable/question"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/btStartItem"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
输出:
答案 1 :(得分:0)
答案 2 :(得分:0)
让TextView显示它只是将android:frameLayout的layout_width从0dp更改为wrap_content:
(...)
<FrameLayout
android:id="@+id/frameLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
(...)
答案 3 :(得分:0)
将FrameLayout高度从 0dp 更改为 wrap_content
<FrameLayout
android:id="@+id/frameLayout"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/btStartItem"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
到
<FrameLayout
android:id="@+id/frameLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/btStartItem"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">