我研究约束布局。我使用链来连接两个textviews tvNameReview和tvTimePeriodReview。但正如您可以看到tvNameReview中的文本是否非常大,它会叠加在tvTimePeriodReview上。我该如何解决? [所以看起来像在工作室编辑器中] [1] [1]:https://i.stack.imgur.com/COsd8.png编码我的布局:
<?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:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.constraint.Guideline
android:id="@+id/gl2Review"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_begin ="20dp"/>
<android.support.constraint.Guideline
android:id="@+id/gl1Review"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_begin="20dp"/>
<TextView
android:id="@+id/timeReview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintLeft_toRightOf="@+id/gl1Review"
app:layout_constraintTop_toTopOf="@+id/gl2Review"
tools:text="10:15" />
<Space
android:id="@+id/space1Review"
android:layout_width="40dp"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@+id/timeReview"/>
<android.support.constraint.Guideline
android:id="@+id/gl3Review"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_end="20dp"/>
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintRight_toLeftOf="@+id/gl3Review"
app:layout_constraintTop_toBottomOf="@+id/gl2Review"
app:srcCompat="@mipmap/ic_launcher" />
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
app:layout_constraintRight_toLeftOf="@+id/gl3Review"
app:layout_constraintTop_toBottomOf="@+id/textView4" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
app:layout_constraintRight_toLeftOf="@+id/gl3Review"
app:layout_constraintTop_toBottomOf="@+id/imageView" />
<android.support.constraint.Barrier
android:id="@+id/b1Constraint"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:constraint_referenced_ids="imageView, textView5, textView4"
app:barrierDirection="left"
app:layout_constraintTop_toBottomOf="@+id/gl2Review"
app:layout_constraintBottom_toBottomOf="parent"/>
<View
android:id="@+id/viewReview"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@+id/gl2Review"
app:layout_constraintLeft_toRightOf="@+id/space1Review"
app:layout_constraintRight_toLeftOf="@+id/b1Constraint"/>
<TextView
android:id="@+id/tvNameReview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="@+id/viewReview"
app:layout_constraintRight_toLeftOf="@+id/tvTimePeriodReview"
app:layout_constraintTop_toBottomOf="@+id/gl2Review"
tools:text="Very very long name reviewwwww"
app:layout_constraintHorizontal_chainStyle="spread_inside"
android:ellipsize="end"/>
<TextView
android:id="@+id/tvTimePeriodReview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@+id/gl2Review"
app:layout_constraintLeft_toRightOf="@+id/tvNameReview"
app:layout_constraintRight_toRightOf="@+id/viewReview"
tools:text="10:15-11:45"
android:layout_marginTop="-1dp"
app:layout_constraintHorizontal_chainStyle="spread_inside"/>
</android.support.constraint.ConstraintLayout>
答案 0 :(得分:0)
可以使用加权链来完成。
@Configuration
public class ThymLeafConfig {
@Bean
public SpringTemplateEngine springTemplateEngine() {
SpringTemplateEngine templateEngine = new SpringTemplateEngine();
templateEngine.addTemplateResolver(htmlTemplateResolver());
return templateEngine;
}
@Bean
public ITemplateResolver htmlTemplateResolver(){
SpringResourceTemplateResolver emailTemplateResolver = new SpringResourceTemplateResolver();
emailTemplateResolver.setPrefix("/templates/");
emailTemplateResolver.setSuffix(".html");
emailTemplateResolver.setTemplateMode(StandardTemplateModeHandlers.HTML5.getTemplateModeName());
emailTemplateResolver.setCharacterEncoding(StandardCharsets.UTF_8.name());
return emailTemplateResolver;
}
只需设置文字视图&#39;宽度为0dp。