logo
down
shadow

ImageView below adview stop layout jump after ad loads


ImageView below adview stop layout jump after ad loads

Content Index :

ImageView below adview stop layout jump after ad loads
Tag : android , By : user171555
Date : November 26 2020, 03:04 PM

I hope this helps . TL;DR
The fastest solution would be to change your ad view android:layout_height="wrap_content" into android:layout_height="fixed size" so your ad view will have a single height and won't change because of its wrap_content attribute (If your ad view is not loaded you can think of wrap_content as height of 0 and only after its loaded it will have height, thus the layout jump).
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout   
  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:context=".MainActivity">

<Button
    android:id="@+id/adView"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_marginTop="8dp"
    android:layout_marginBottom="8dp"
    app:layout_constraintHeight_percent="0.08"
    android:text="add view"
    app:layout_constraintBottom_toTopOf="@+id/guideline"
    app:layout_constraintTop_toTopOf="parent" />


<ImageView
    android:id="@+id/imageView1"
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:src="@drawable/ic_launcher_background"
    android:scaleType="fitXY"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHeight_percent="0.4"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="@+id/guideline"
    app:layout_constraintWidth_percent="0.6" />

<TextView
    android:id="@+id/a1"
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:gravity="center"
    android:text="a1"
    app:layout_constraintHeight_percent="0.08"
    app:layout_constraintWidth_percent="0.25"
    app:layout_constraintBottom_toTopOf="@+id/a3"
    app:layout_constraintEnd_toStartOf="@+id/a2"
    app:layout_constraintHorizontal_bias="0.5"
    app:layout_constraintStart_toStartOf="@+id/imageView1"
    app:layout_constraintTop_toBottomOf="@+id/imageView1" />

<TextView
    android:id="@+id/a2"
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:gravity="center"
    android:text="a2"
    app:layout_constraintHeight_percent="0.08"
    app:layout_constraintWidth_percent="0.25"
    app:layout_constraintBottom_toBottomOf="@+id/a1"
    app:layout_constraintEnd_toEndOf="@+id/imageView1"
    app:layout_constraintHorizontal_bias="0.5"
    app:layout_constraintStart_toEndOf="@+id/a1"
    app:layout_constraintTop_toTopOf="@+id/a1"
    app:layout_constraintVertical_bias="0.0" />

<TextView
    android:id="@+id/a3"
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:gravity="center"
    android:text="a3"
    app:layout_constraintHeight_percent="0.08"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="@+id/a1"
    app:layout_constraintStart_toStartOf="@+id/a1"
    app:layout_constraintTop_toBottomOf="@+id/a1" />

<androidx.constraintlayout.widget.Guideline
    android:id="@+id/guideline"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    app:layout_constraintGuide_percent=".2" />

<TextView
    android:id="@+id/a4"
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:gravity="center"
    android:text="a4"
    app:layout_constraintBottom_toBottomOf="@+id/a3"
    app:layout_constraintEnd_toEndOf="@+id/a2"
    app:layout_constraintHeight_percent="0.08"
    app:layout_constraintStart_toStartOf="@+id/a2"
    app:layout_constraintTop_toTopOf="@+id/a3" />


</androidx.constraintlayout.widget.ConstraintLayout>

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

AdView layout takes up whole screen


Tag : android , By : George Handlin
Date : March 29 2020, 07:55 AM
I wish this help you I have the following XML layout: , Try to set the height of the ad to '50dp' and post your results

Linear Layout on a Canvas which contains an AdView


Tag : android , By : Thx1138.6
Date : March 29 2020, 07:55 AM
it helps some times Before anything else, to my understanding, the canvas is actually an AdView - my guess is you're using AdMob. But, that's a View.
A LinearLayout is a ViewGroup and as its Javadoc description says, it's a view that contains Views - imagine it's a container of Views. You're supposed to use ViewGroups within ViewGroups only, not have them within Views. A View is supposed to draw something simple: a text, an image, a drawable or any combination of these. I would suggest to start reading the User Interface article from developers.

In android tabbed activity, the tab with the imageview loads slowly. Is there a better way to code imageview?


Tag : android , By : Picoman Games
Date : March 29 2020, 07:55 AM
I hope this helps you . For tabbed activity,(2048 * 1152) this resolution is too large. Use Picasso or other Glide library to resize your image.
Picasso.with(this)
                .load("url Address")
            //  .loadFromResource(R.drwable.your_image)  
                .resize(200,200)
                .into(imageView);
compile 'com.squareup.picasso:picasso:2.5.2'

how to create AdView programmatically without layout.xml


Tag : java , By : Bimal Poudel
Date : March 29 2020, 07:55 AM
Hope that helps i just found the answer and you have no idea how stupid i was for not trying it once; the solution was to simply delete this from code" mAdView = findViewById(R.id.adView); "

AdView doesn't show ads at the bottom of the linear layout layout -Why So?


Tag : android , By : Mark W
Date : March 29 2020, 07:55 AM
Hope that helps Add one new attributes android:layout_weight="1" and Modify height of scroll view as below.
    android:layout_height="0dp"
    android:layout_weight="1"
<ScrollView
    android:id="@+id/scrollView"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1">
Related Posts Related QUESTIONS :
  • How to reference a timerPicker in android studio using kotlin
  • Firebase Crashlytics - get stacktrace info to display during CrashlyticsListener.crashlyticsDidDetectCrashDuringPrevious
  • Schedule a repeating alarm clock
  • Can't assign values outside onTouchListener
  • Is setContentView() needed to inflate a fragment?
  • Why instead of string method returns Kotlin.Unit?
  • Retrofit slash as Query
  • When does onCreateView() get called in this app?
  • Fragment is reloaded each time after rejecting location permission
  • How to read ViewModel data from sttrings.xml list of items
  • Flutter doctor does not see vs code ,VS code does not detect flutter/bin
  • How to build aar in flutter
  • Is displayMetrix xdpi and ydpi accurate?
  • How to detect doubletap on a View?
  • how to play an encrypted file in Android
  • Android: keytool error on the command line when locating debug.keystore
  • Android paint/canvas issue; drawing smooth curves
  • Problems with starting an activity in onStart
  • Performance of map overlay in conjunction with ItemizedOverlay is very poor
  • How to change android indeterminate ProgressBar color?
  • How do I change the Mobile Country Code (MCC) in the Android Emulator?
  • Stop Progressbar manual scrolling in Android
  • Android: download large file
  • Android : uploaded .apk file to server but cant download that .apk file
  • How do I distribute Android app to beta tester without using Market
  • Android Unable to launch the Inbox from a notification
  • Android: Ringer mode changed to silent doesn't stop the phone vibrating
  • Change the side the text appears on a radio button
  • Check the memory usage anp cpu and power of an application in android
  • What is the String 'volumeName' argument of MediaStore.Audio.Playlists.Members.getContentUri referring to?
  • Playing Multiple sounds at the same time in Android
  • Android: how to change the time in emulator?
  • close the soft key pad when i click on other views in android
  • Setting the position within a spinner
  • How to play ringtone/alarm sound in Android
  • How to adjust text font size to fit textview
  • "Android 2.x" vs "Google APIs" for Android AVD Setup
  • How to center buttons on screen horizontally and vertically plus equidistant apart?
  • Discrete seekbar in Android app?
  • Gradle Build Fails - Illegal exception table range in class file com/google/wireless/android/sdk/stats/GradleBuildMemory
  • register has type Long (High Half) but expected Long (Low Half)
  • Is it good idea to use Dispatcher.Main with delay( )?
  • WebView and Advanced View is Not loading partiucalr URL
  • How to show three dots at the end of text view
  • Is it possible to run macros within Android Studio project?
  • Adding a button with default appearance but changed background color
  • What is best way to show notification at a certain time in Android?
  • Jetifier not working when library uses android component and app uses androidx component
  • How can I write the contents of an image in a filesystem
  • Retrieve a list of images from the Database and display them using a ListView?
  • java.lang.SecurityException: my location requires permission ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION
  • Timer/hourglass wont stop
  • How can I make AndroidX the default library for new Android projects?
  • Is it okay to delete buildToolsVersion android studio because of a warning in the Asyncstorage library?
  • Can I call a class that doesn't have an activity withIntent?
  • Android TextView fontFamily not working when set via TextAppearance
  • Unable to find nearby places
  • Is there any way to launch my application right away without 'Ok Google"?
  • Places api set location biased based on current location
  • Layout Preview is not displaying layout when Material Design is added
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com