私はCircularImageViewを使用して人物のプロフィール画像を設定します。何らかの理由で、なぜ画像のプレースホルダがプロファイル画面に表示されないのかわかりませんでした。ユーザーがプロファイルイメージセットを持たない場合、イメージのプレースホルダはまったく表示されません。しかし、同じページでカメラまたはギャラリーのインテントを使用してイメージを設定すると、そのイメージがプレースホルダに表示されます。私はその問題が何であるかを知るのは無駄だ。ユーザーがプロファイルCircularImageViewに画像を持たない場合、デフォルトのsrc属性を表示しない理由を教えてください。src drawableが画面に表示されない
下記のxmlファイルを転記してください。
<ScrollView 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"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="8dp">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context="com.project.group.projectga.fragments.ProfileFragment">
<android.support.constraint.ConstraintLayout
android:id="@+id/photoLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/profileBackground"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/profile_background"
tools:ignore="ContentDescription" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:orientation="horizontal"
android:padding="10dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/photoCircle">
<mehdi.sakout.fancybuttons.FancyButton
android:id="@+id/cameraButton"
style="@style/fancyButtonProfile"
app:fb_defaultColor="@color/colorPrimary"
app:fb_radius="30dp"
app:fb_text="Camera"
app:fb_textSize="15sp" />
<mehdi.sakout.fancybuttons.FancyButton
android:id="@+id/galleryButton"
style="@style/fancyButtonProfile"
android:layout_marginStart="10dp"
android:layout_toEndOf="@+id/cameraButton"
app:fb_defaultColor="@color/colorPrimary"
app:fb_radius="30dp"
app:fb_text="Gallery"
app:fb_textSize="15sp" />
<mehdi.sakout.fancybuttons.FancyButton
android:id="@+id/removeButton"
style="@style/fancyButtonProfile"
android:layout_marginStart="10dp"
android:layout_toEndOf="@+id/galleryButton"
app:fb_borderColor="@color/colorPrimary"
app:fb_borderWidth="2dp"
app:fb_defaultColor="@android:color/transparent"
app:fb_radius="30dp"
app:fb_text="Remove"
app:fb_textColor="@color/colorPrimary" />
</RelativeLayout>
<android.support.constraint.ConstraintLayout
android:id="@+id/photoCircle"
android:layout_width="128dp"
android:layout_height="128dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.mikhaellopez.circularimageview.CircularImageView
android:id="@+id/circularPhoto"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_centerInParent="true"
android:cropToPadding="true"
android:scaleType="centerCrop"
android:src="@drawable/ic_account_circle_white_24dp"
app:civ_shadow="true"
app:civ_shadow_radius="24"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>
<android.support.constraint.ConstraintLayout
android:id="@+id/aboutDividerLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="24dp"
android:layout_marginStart="24dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/photoLayout">
<ImageView
android:id="@+id/aboutDivider"
android:layout_width="336dp"
android:layout_height="2dp"
android:background="@color/md_grey_300"
android:scaleType="fitXY"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@android:drawable/divider_horizontal_bright"
tools:ignore="ContentDescription" />
<TextView
android:id="@+id/aboutLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:background="@color/md_light_background"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:text="@string/aboutLabel"
android:textAlignment="center"
android:textColor="@color/accent"
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
ユーザーが初めて作成されたときの画像です。
これは、画像がギャラリーを使用して設定された後にプロフィール画像が設定された後です。
事前にどうもありがとうと任意の助けが理解されます。
findViewById(R.id.circularPhoto).setBackgroundResource(R.drawable.chrysanthemum)
か:あなたの目的は、あなたがあなたの活動/フラグメントのコードからデフォルトの画像を設定することができ、デフォルトの画像を表示する場合、私はフラグメント
Picasso.with(getContext()).load(profile.getProfile()).error(R.drawable.ic_error_outline_black_24dp).into(circularProfilePhoto);
多分、幅と高さが0であることと関係がありますか? デフォルトの人物を追加して写真を撮ったときにその人物を変更しないのはなぜですか? – nKalai
幅と高さの場合は、ギャラリーとカメラから画像を設定しても表示されません。 –