kos*_*sas 3 android android-layout android-constraintlayout
我该如何调整TextView结束的ImageView那TextView会是centered vertically用ConstraintLayout我设法将其调整到年底ImageView,但它不是垂直居中,因为ImageView是大一点比TextView我知道如何用它来办RelativeLayout,但想使用的最佳实践,并且只使用ConstraintLayout
以下是它应该如何显示的示例(云图标和文本上次备份)
只要使用app:layout_constraintTop_toTopOf和app:layout_constraintBottom_toBottomOf在一起,就会造成TextView中心垂直对齐的ImageView.
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_launcher"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:text="Last Backup"
app:layout_constraintStart_toEndOf="@+id/imageView"
app:layout_constraintTop_toTopOf="@+id/imageView"
app:layout_constraintBottom_toBottomOf="@+id/imageView"
/>
Run Code Online (Sandbox Code Playgroud)
drawable像这样使用left 作为你的 TextView 并根据需要按gravity你的 root进行更改layout
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawablePadding="15dp"
android:drawableLeft="@drawable/google"
android:text="@string/textGoogle" />
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5658 次 |
| 最近记录: |