Skip to content

Commit

Permalink
app base
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuls2 committed Apr 15, 2022
1 parent 43cd1e1 commit 3796951
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ protected void onCreate(Bundle savedInstanceState) {
Glide.with(this).load(R.drawable.img_back_cus2).fitCenter().into(imgBack);

PuppyView puppyView = new PuppyView(layBack, this);
puppyView.setColor();

imgBack.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
Expand Down
12 changes: 10 additions & 2 deletions app/src/main/java/com/example/togaether/PuppyView.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class PuppyView {
LayoutInflater layoutInflater;
AppCompatActivity act;
View puppyView, puppy;
ImageView imgFace;
ImageView imgFace, imgBody, imgNose, imgMouth, imgEyeLeft, imgEyeRight, imgEarLeft, imgEarRight;
int w, h;

PuppyView(ViewGroup lay, AppCompatActivity act) {
Expand All @@ -39,6 +39,13 @@ public void onGlobalLayout() {
});

imgFace = (ImageView) puppyView.findViewById(R.id.img_face1);
imgBody = (ImageView) puppyView.findViewById(R.id.img_body);
imgMouth = (ImageView) puppyView.findViewById(R.id.img_mouth);
imgNose = (ImageView) puppyView.findViewById(R.id.img_nose);
imgEarLeft = (ImageView) puppyView.findViewById(R.id.img_ear_left);
imgEarRight = (ImageView) puppyView.findViewById(R.id.img_ear_right);
imgEyeLeft = (ImageView) puppyView.findViewById(R.id.img_eye_left);
imgEyeRight = (ImageView) puppyView.findViewById(R.id.img_eye_right);
}
public void setPosition(int x, int y) {
puppy.setTranslationX((int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, x, act.getResources().getDisplayMetrics()) - w/2); //puppy.findViewById(R.id.lay_puppy).
Expand All @@ -49,6 +56,7 @@ public void setPositionPX(int x, int y) {
puppy.setTranslationY(y - h/2);
}
public void setColor() {
imgFace.setColorFilter(Color.parseColor("#e28743"), PorterDuff.Mode.SRC_IN);
imgFace.setColorFilter(Color.parseColor("#e28743"), PorterDuff.Mode.MULTIPLY);
imgBody.setColorFilter(Color.parseColor("#e28743"), PorterDuff.Mode.MULTIPLY);
}
}
21 changes: 21 additions & 0 deletions app/src/main/res/layout/puppy_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,25 @@
app:srcCompat="@drawable/img_cus_eye_1"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="0dp" />

<ImageView
android:id="@+id/img_ear_left"
android:layout_width="100dp"
android:layout_height="100dp"
android:translationX="-25dp"
android:translationY="-30dp"
app:srcCompat="@drawable/img_cus_ear_1"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="0dp" />

<ImageView
android:id="@+id/img_ear_right"
android:layout_width="100dp"
android:layout_height="100dp"
android:translationX="25dp"
android:translationY="-30dp"
android:scaleX="-1"
app:srcCompat="@drawable/img_cus_ear_1"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="0dp" />
</androidx.constraintlayout.widget.ConstraintLayout>

0 comments on commit 3796951

Please sign in to comment.