在这个简单的视图中,我想在视图的右侧有CircleImageView
,但是在编译项目或在其中添加其他视图之后,该视图始终停留在左侧并从左侧移去该视图的左上角不能解决我的问题
例如我想拥有
,但是在将其他视图添加到容器后,该视图始终停留在左侧
<?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:funky="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/circleImageView"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginTop="110dp"
android:layout_marginEnd="30dp"
android:scaleType="centerCrop"
android:src="@drawable/photo_female_8"
app:civ_border_color="@color/overlay_dark_10"
app:civ_border_width="2dp"
app:layout_constraintEnd_toEndOf="parent"
funky:layout_constraintStart_toStartOf="parent"
funky:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
我该如何解决这个问题?
答案 0 :(得分:0)
您应该删除开始约束,以保持正确的imageview-
<?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:funky="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/circleImageView"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginTop="110dp"
android:layout_marginEnd="30dp"
android:scaleType="centerCrop"
android:src="@drawable/photo_female_8"
app:civ_border_color="@color/overlay_dark_10"
app:civ_border_width="2dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
layout_constraintHorizontal_bias="1" />
</android.support.constraint.ConstraintLayout>
您还可以使用layout_constraintHorizontal_bias-
shutil
答案 1 :(得分:0)
您也可以使用RelativeLayout,
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:funky="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/circleImageView"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginTop="110dp"
android:layout_marginEnd="30dp"
android:scaleType="centerCrop"
android:src="@drawable/photo_female_8"
app:civ_border_color="@color/overlay_dark_10"
app:civ_border_width="2dp"
android:layout_alignParentRight="true"
/>
</RelativeLayout>