Skip to content

Commit a82cdd8

Browse files
Merge pull request #192 from MihaiCristianCondrea/codex/add-animated-size-change-for-card-views
Animate native ad view size changes
2 parents fa9dcf5 + 4a7a57d commit a82cdd8

File tree

7 files changed

+11
-0
lines changed

7 files changed

+11
-0
lines changed

app/src/main/java/com/d4rk/androidtutorials/java/ads/views/NativeAdBannerView.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.d4rk.androidtutorials.java.ads.views;
22

3+
import android.animation.LayoutTransition;
34
import android.content.Context;
45
import android.content.res.TypedArray;
56
import android.util.AttributeSet;
@@ -38,6 +39,10 @@ public NativeAdBannerView(@NonNull Context context, @Nullable AttributeSet attrs
3839
}
3940

4041
private void init(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
42+
LayoutTransition transition = new LayoutTransition();
43+
transition.enableTransitionType(LayoutTransition.CHANGING);
44+
setLayoutTransition(transition);
45+
4146
if (attrs != null) {
4247
try (TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.NativeAdBannerView, defStyleAttr, 0)) {
4348
layoutRes = a.getResourceId(R.styleable.NativeAdBannerView_nativeAdLayout, R.layout.ad_home_banner_large);

app/src/main/res/layout/ad_about.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
android:layout_width="match_parent"
1111
android:layout_height="wrap_content"
1212
android:layout_marginHorizontal="24dp"
13+
android:animateLayoutChanges="true"
1314
app:cardPreventCornerOverlap="true"
1415
app:cardUseCompatPadding="false"
1516
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.CardViewBottomRounded">

app/src/main/res/layout/ad_android_studio_list.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
android:layout_width="match_parent"
1111
android:layout_height="wrap_content"
1212
android:layout_marginHorizontal="16dp"
13+
android:animateLayoutChanges="true"
1314
app:cardCornerRadius="4dp">
1415

1516
<androidx.appcompat.widget.LinearLayoutCompat

app/src/main/res/layout/ad_home_banner_large.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
style="@style/Widget.Material3.CardView.Outlined"
1010
android:layout_width="match_parent"
1111
android:layout_height="wrap_content"
12+
android:animateLayoutChanges="true"
1213
app:cardCornerRadius="24dp">
1314

1415
<androidx.appcompat.widget.LinearLayoutCompat

app/src/main/res/layout/ad_home_banner_small.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
android:layout_marginHorizontal="16dp"
1313
android:layout_marginTop="2dp"
1414
android:layout_marginBottom="16dp"
15+
android:animateLayoutChanges="true"
1516
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.CardViewBottomRounded">
1617

1718
<androidx.appcompat.widget.LinearLayoutCompat

app/src/main/res/layout/ad_lesson_code.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
style="@style/Widget.Material3.CardView.Outlined"
1010
android:layout_width="match_parent"
1111
android:layout_height="wrap_content"
12+
android:animateLayoutChanges="true"
1213
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.CardViewBottomRounded">
1314

1415
<androidx.appcompat.widget.LinearLayoutCompat

app/src/main/res/layout/ad_support.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
style="@style/Widget.Material3.CardView.Outlined"
1010
android:layout_width="match_parent"
1111
android:layout_height="wrap_content"
12+
android:animateLayoutChanges="true"
1213
app:cardCornerRadius="24dp">
1314

1415
<androidx.appcompat.widget.LinearLayoutCompat

0 commit comments

Comments
 (0)