SupportMapFragment is hiding admob banner
I'm trying to show admob banner under the Google Maps Fragment, at the bottom of the screen but without covering any part of the map.
I'm currently using LinearLayout but Google Maps Fragment takes all the remaining height of the screen and the AdView is not showing. How to do that?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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"
tools:context=".activities.MainActivity"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="@+id/my_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
<fragment
android:id="@+id/origin_place_autocomplete"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"
/>
<fragment
android:id="@+id/destination_place_autocomplete"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"
/>
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<com.google.android.gms.ads.AdView xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
ads:adSize="SMART_BANNER"
ads:adUnitId="ca-app-pub-XXX">
</com.google.android.gms.ads.AdView>
</LinearLayout>
android xml android-layout
add a comment |
I'm trying to show admob banner under the Google Maps Fragment, at the bottom of the screen but without covering any part of the map.
I'm currently using LinearLayout but Google Maps Fragment takes all the remaining height of the screen and the AdView is not showing. How to do that?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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"
tools:context=".activities.MainActivity"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="@+id/my_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
<fragment
android:id="@+id/origin_place_autocomplete"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"
/>
<fragment
android:id="@+id/destination_place_autocomplete"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"
/>
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<com.google.android.gms.ads.AdView xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
ads:adSize="SMART_BANNER"
ads:adUnitId="ca-app-pub-XXX">
</com.google.android.gms.ads.AdView>
</LinearLayout>
android xml android-layout
Use frameLayout or constraintlayout and also check AdView key is proper
– AD 10
2 days ago
add a comment |
I'm trying to show admob banner under the Google Maps Fragment, at the bottom of the screen but without covering any part of the map.
I'm currently using LinearLayout but Google Maps Fragment takes all the remaining height of the screen and the AdView is not showing. How to do that?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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"
tools:context=".activities.MainActivity"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="@+id/my_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
<fragment
android:id="@+id/origin_place_autocomplete"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"
/>
<fragment
android:id="@+id/destination_place_autocomplete"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"
/>
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<com.google.android.gms.ads.AdView xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
ads:adSize="SMART_BANNER"
ads:adUnitId="ca-app-pub-XXX">
</com.google.android.gms.ads.AdView>
</LinearLayout>
android xml android-layout
I'm trying to show admob banner under the Google Maps Fragment, at the bottom of the screen but without covering any part of the map.
I'm currently using LinearLayout but Google Maps Fragment takes all the remaining height of the screen and the AdView is not showing. How to do that?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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"
tools:context=".activities.MainActivity"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="@+id/my_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
<fragment
android:id="@+id/origin_place_autocomplete"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"
/>
<fragment
android:id="@+id/destination_place_autocomplete"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"
/>
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<com.google.android.gms.ads.AdView xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
ads:adSize="SMART_BANNER"
ads:adUnitId="ca-app-pub-XXX">
</com.google.android.gms.ads.AdView>
</LinearLayout>
android xml android-layout
android xml android-layout
asked 2 days ago
e.etnanne.etnann
123
123
Use frameLayout or constraintlayout and also check AdView key is proper
– AD 10
2 days ago
add a comment |
Use frameLayout or constraintlayout and also check AdView key is proper
– AD 10
2 days ago
Use frameLayout or constraintlayout and also check AdView key is proper
– AD 10
2 days ago
Use frameLayout or constraintlayout and also check AdView key is proper
– AD 10
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
Put the Map Fragment into a LinearLayout and give that Linear Layout an
android:layout_height="0dp"
android:layout_weight="1"
It works. Can you explain me how this solution (and weight) work?
– e.etnann
2 days ago
Your Map Fragment will attempt to fill all of the available space. This leaves no space left for fragments underneath. The LinearLayout is effectively acting as a "fill what you can" with what screen space is left. The Weighting is for if you were to be using more than one element & you wanted to share whats left of the space between them. E.g. 2 elements with the same weight would be given a 50% slice of the space. If you were to weight one element more than the other, they would gain a higher % of whats left. The values dependant on what weight values you provide.
– ManxDev
2 days ago
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54252846%2fsupportmapfragment-is-hiding-admob-banner%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Put the Map Fragment into a LinearLayout and give that Linear Layout an
android:layout_height="0dp"
android:layout_weight="1"
It works. Can you explain me how this solution (and weight) work?
– e.etnann
2 days ago
Your Map Fragment will attempt to fill all of the available space. This leaves no space left for fragments underneath. The LinearLayout is effectively acting as a "fill what you can" with what screen space is left. The Weighting is for if you were to be using more than one element & you wanted to share whats left of the space between them. E.g. 2 elements with the same weight would be given a 50% slice of the space. If you were to weight one element more than the other, they would gain a higher % of whats left. The values dependant on what weight values you provide.
– ManxDev
2 days ago
add a comment |
Put the Map Fragment into a LinearLayout and give that Linear Layout an
android:layout_height="0dp"
android:layout_weight="1"
It works. Can you explain me how this solution (and weight) work?
– e.etnann
2 days ago
Your Map Fragment will attempt to fill all of the available space. This leaves no space left for fragments underneath. The LinearLayout is effectively acting as a "fill what you can" with what screen space is left. The Weighting is for if you were to be using more than one element & you wanted to share whats left of the space between them. E.g. 2 elements with the same weight would be given a 50% slice of the space. If you were to weight one element more than the other, they would gain a higher % of whats left. The values dependant on what weight values you provide.
– ManxDev
2 days ago
add a comment |
Put the Map Fragment into a LinearLayout and give that Linear Layout an
android:layout_height="0dp"
android:layout_weight="1"
Put the Map Fragment into a LinearLayout and give that Linear Layout an
android:layout_height="0dp"
android:layout_weight="1"
answered 2 days ago
ManxDevManxDev
588
588
It works. Can you explain me how this solution (and weight) work?
– e.etnann
2 days ago
Your Map Fragment will attempt to fill all of the available space. This leaves no space left for fragments underneath. The LinearLayout is effectively acting as a "fill what you can" with what screen space is left. The Weighting is for if you were to be using more than one element & you wanted to share whats left of the space between them. E.g. 2 elements with the same weight would be given a 50% slice of the space. If you were to weight one element more than the other, they would gain a higher % of whats left. The values dependant on what weight values you provide.
– ManxDev
2 days ago
add a comment |
It works. Can you explain me how this solution (and weight) work?
– e.etnann
2 days ago
Your Map Fragment will attempt to fill all of the available space. This leaves no space left for fragments underneath. The LinearLayout is effectively acting as a "fill what you can" with what screen space is left. The Weighting is for if you were to be using more than one element & you wanted to share whats left of the space between them. E.g. 2 elements with the same weight would be given a 50% slice of the space. If you were to weight one element more than the other, they would gain a higher % of whats left. The values dependant on what weight values you provide.
– ManxDev
2 days ago
It works. Can you explain me how this solution (and weight) work?
– e.etnann
2 days ago
It works. Can you explain me how this solution (and weight) work?
– e.etnann
2 days ago
Your Map Fragment will attempt to fill all of the available space. This leaves no space left for fragments underneath. The LinearLayout is effectively acting as a "fill what you can" with what screen space is left. The Weighting is for if you were to be using more than one element & you wanted to share whats left of the space between them. E.g. 2 elements with the same weight would be given a 50% slice of the space. If you were to weight one element more than the other, they would gain a higher % of whats left. The values dependant on what weight values you provide.
– ManxDev
2 days ago
Your Map Fragment will attempt to fill all of the available space. This leaves no space left for fragments underneath. The LinearLayout is effectively acting as a "fill what you can" with what screen space is left. The Weighting is for if you were to be using more than one element & you wanted to share whats left of the space between them. E.g. 2 elements with the same weight would be given a 50% slice of the space. If you were to weight one element more than the other, they would gain a higher % of whats left. The values dependant on what weight values you provide.
– ManxDev
2 days ago
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54252846%2fsupportmapfragment-is-hiding-admob-banner%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Use frameLayout or constraintlayout and also check AdView key is proper
– AD 10
2 days ago