Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6731013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:28:39+00:00 2026-05-26T10:28:39+00:00

I’m using a custom layout to display preferences so that I can insert an

  • 0

I’m using a custom layout to display preferences so that I can insert an ad banner at the bottom of the screen. The idea is to have the banner stick to the bottom of the page, and have the preferences displayed in the rest of the screen in a scrollview.
I have a problem with the height taken by the preferences.
I’ve currently hardcoded it to “2000dip” in the XML layout below.

It works fine, the banner stays at the bottom, preferences at the top in a scrollable view.

But having a hardcoded height value is bad and I’d like it to automatically being set to the exact height taken by the preferences because currently it is either too short or too long (with a blank area after the preferences).
I’ve tried to replace the hardcoded value with wrap_content or fill_parent with no success.
Any idea?

In my PreferenceActivity I’ve included the following two lines:

    setContentView(R.layout.preferences_scrollable);
    addPreferencesFromResource(R.layout.preferences);

And I’ve defined a layout preferences_scrollable in the xml file preferences_scrollable.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:orientation="vertical">

    <ScrollView android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:layout_weight="1"
        android:id="@+id/pref_scrollable_sv">

        <LinearLayout android:layout_width="fill_parent"
            android:layout_height="wrap_content" android:orientation="vertical"
            android:id="@+id/pref_scrollable_ll">

            <ListView android:id="@android:id/list"
                android:layout_width="fill_parent" android:layout_height="2000dip">

            </ListView>
        </LinearLayout>
    </ScrollView>
    <LinearLayout android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:orientation="vertical">
        <com.google.ads.AdView android:id="@+id/ad"
            ads:adSize="BANNER" android:layout_width="fill_parent"
            ads:loadAdOnCreate="true" ads:adUnitId="xxx"
            android:layout_height="wrap_content" 
            android:layout_weight="0"/>
    </LinearLayout>
</LinearLayout>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:28:40+00:00Added an answer on May 26, 2026 at 10:28 am

    Using the attribute “android:fillViewport” in the scrollview makes it have a correct height. So that would be the solution except that with this attribute, the view doesn’t scroll, or scrolls very badly. Looks like an Android bug to me.

    Anyway, the solution that works is to drop the ScrollView and instead use a LinearLayout (that supports scrolling as well). The layout correctly working with a scrollable preference list (content filled from Java code) on top and an ad banner on the bottom is given below.

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
        android:layout_width="fill_parent" android:layout_height="fill_parent"
        android:orientation="vertical">
    
        <LinearLayout android:layout_width="fill_parent"
            android:id="@+id/ad_layout" android:layout_height="wrap_content"
            android:orientation="vertical" 
            android:layout_alignParentBottom="true">
    
            <com.google.ads.AdView android:id="@+id/ad"
                ads:adSize="BANNER" android:layout_width="fill_parent"
                ads:loadAdOnCreate="true" ads:adUnitId="xxx"
                android:layout_height="wrap_content" primaryTextColor="#FFFFFF"
                secondaryTextColor="#CCCCCC" />
        </LinearLayout>
        <LinearLayout android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="horizontal"
            android:layout_above="@+id/ad_layout">
    
            <ListView android:id="@android:id/list" android:layout_width="fill_parent"
                android:layout_height="wrap_content">
            </ListView>
    </LinearLayout>     
    </RelativeLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have thousands of HTML files to process using Groovy/Java and I need to
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.