Skip to content

Commit

Permalink
Create dimen resource file and refactor xml layout
Browse files Browse the repository at this point in the history
  • Loading branch information
yagmurerdogan committed Oct 26, 2021
1 parent d0a4045 commit 16a01ba
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class MainActivity : AppCompatActivity() {
private fun animateMainActivity() {
startAnimSet(
with(binding) {
arrayOf(cloudImageView, cloudImageView2, cloudImageView3).forEach { cloudImage ->
arrayOf(cloudSmallImage, cloudMediumImage, cloudLargeImage).forEach { cloudImage ->
cloudImage.createAnim(TRANSLATION_X, ZERO_FLOAT, NEGATIVE_HALF_TOUR)
.makeInfiniteAndReverse()
}
Expand Down
48 changes: 24 additions & 24 deletions CarAnimation/app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,33 @@
app:layout_constraintTop_toTopOf="parent" />

<ImageView
android:id="@+id/cloud_imageView"
android:id="@+id/cloud_large_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginTop="100dp"
android:layout_marginStart="@dimen/thirty_two_dp"
android:layout_marginTop="@dimen/one_hundred_dp"
android:contentDescription="@string/image_description"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/night_layout"
app:srcCompat="@drawable/ic_cloud" />

<ImageView
android:id="@+id/cloud_imageView2"
android:layout_width="86dp"
android:layout_height="100dp"
android:layout_marginStart="148dp"
android:layout_marginTop="76dp"
android:id="@+id/cloud_medium_image"
android:layout_width="@dimen/eighty_six_dp"
android:layout_height="@dimen/one_hundred_dp"
android:layout_marginStart="@dimen/one_hundred_forty_eight_dp"
android:layout_marginTop="@dimen/seventy_six_dp"
android:contentDescription="@string/image_description"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/night_layout"
app:srcCompat="@drawable/ic_cloud" />

<ImageView
android:id="@+id/cloud_imageView3"
android:layout_width="67dp"
android:layout_height="64dp"
android:layout_marginStart="72dp"
android:layout_marginTop="56dp"
android:id="@+id/cloud_small_image"
android:layout_width="@dimen/sixty_seven_dp"
android:layout_height="@dimen/sixty_four_dp"
android:layout_marginStart="@dimen/seventy_two_dp"
android:layout_marginTop="@dimen/fifty_six_dp"
android:contentDescription="@string/image_description"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/night_layout"
Expand All @@ -56,8 +56,8 @@
android:id="@+id/sun_imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:layout_marginEnd="32dp"
android:layout_marginTop="@dimen/one_hundred_dp"
android:layout_marginEnd="@dimen/thirty_two_dp"
android:contentDescription="@string/image_description"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/night_layout"
Expand All @@ -67,8 +67,8 @@
android:id="@+id/moon_imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:layout_marginEnd="32dp"
android:layout_marginTop="@dimen/one_hundred_dp"
android:layout_marginEnd="@dimen/thirty_two_dp"
android:alpha="0"
android:contentDescription="@string/image_description"
app:layout_constraintEnd_toEndOf="parent"
Expand All @@ -77,8 +77,8 @@

<ImageView
android:id="@+id/road_imageView"
android:layout_width="428dp"
android:layout_height="232dp"
android:layout_width="@dimen/four_hundred_twenty_eight_dp"
android:layout_height="@dimen/two_hundred_thirty_two_dp"
android:contentDescription="@string/image_description"
app:layout_constraintBottom_toBottomOf="@+id/night_layout"
app:layout_constraintEnd_toEndOf="parent"
Expand All @@ -88,8 +88,8 @@

<ImageView
android:id="@+id/car_imageView"
android:layout_width="252dp"
android:layout_height="197dp"
android:layout_width="@dimen/two_hundred_fifty_two_dp"
android:layout_height="@dimen/one_hundred_ninety_seven_dp"
android:contentDescription="@string/image_description"
app:layout_constraintBottom_toBottomOf="@+id/night_layout"
app:layout_constraintEnd_toEndOf="parent"
Expand All @@ -100,10 +100,10 @@
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:layout_marginTop="@dimen/thirty_two_dp"
android:text="@string/just_bored"
android:textColor="@color/white"
android:textSize="36sp"
android:textSize="@dimen/thirty_six_sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
Expand All @@ -114,7 +114,7 @@
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:layout_marginTop="@dimen/thirty_two_dp"
android:backgroundTint="@color/blue_dark"
android:text="@string/button_text"
app:layout_constraintEnd_toEndOf="parent"
Expand Down
20 changes: 20 additions & 0 deletions CarAnimation/app/src/main/res/values/dimen.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- SP Resources -->
<dimen name="thirty_six_sp">36sp</dimen>

<!-- DP Resources -->
<dimen name="thirty_two_dp">32dp</dimen>
<dimen name="one_hundred_dp">100dp</dimen>
<dimen name="eighty_six_dp">86dp</dimen>
<dimen name="one_hundred_forty_eight_dp">148dp</dimen>
<dimen name="seventy_six_dp">76dp</dimen>
<dimen name="seventy_two_dp">72dp</dimen>
<dimen name="sixty_seven_dp">67dp</dimen>
<dimen name="sixty_four_dp">64dp</dimen>
<dimen name="fifty_six_dp">56dp</dimen>
<dimen name="four_hundred_twenty_eight_dp">428dp</dimen>
<dimen name="two_hundred_thirty_two_dp">232dp</dimen>
<dimen name="two_hundred_fifty_two_dp">252dp</dimen>
<dimen name="one_hundred_ninety_seven_dp">197dp</dimen>
</resources>

0 comments on commit 16a01ba

Please sign in to comment.