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 7401917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:36:27+00:00 2026-05-29T04:36:27+00:00

I’m new to Android development and am having an issue with my first app’s

  • 0

I’m new to Android development and am having an issue with my first app’s UI. When a particular activity starts up, the screen position is initially scrolled so that it cuts off the top couple view items in my UI. The issue appears to be with the ExpandableListView and my implementation of it. The Activity wants to place it at the top of the screen initially. How do i prevent this scrolling from happening so that a user will see the top of my activity when they start it?

Any help would be greatly appreciated, thanks guys!

Screenshots: Initial: http://imgur.com/FMba5 Desired: http://imgur.com/oEx1N

Here is the main Layout of the Activity

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrollLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<RelativeLayout
        android:id="@+id/relativeLayout1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

    <TextView
        android:id="@+id/new_league_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:text="League Settings"
        android:textStyle="bold"
        android:layout_gravity="center_horizontal"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:focusable="true"/>

    <TextView
        android:id="@+id/num_players_prompt"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/new_league_title"
        android:text="@string/num_players_prompt"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <Spinner
        android:id="@+id/num_players_spinner"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:drawSelectorOnTop="true"
        android:layout_below="@id/num_players_prompt"
        android:prompt="@string/num_players_prompt" />

    <TextView
        android:id="@+id/roster_size_prompt"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/roster_size_prompt"
        android:layout_below="@id/num_players_spinner"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <Spinner
        android:id="@+id/roster_size_spinner"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/roster_size_prompt" 
        android:prompt="@string/roster_size_prompt" />

     <ExpandableListView
         android:id="@+id/scoring_settings_list"
         android:layout_width="fill_parent"
         android:layout_height="1000dp"
         android:focusable="false"
         android:layout_below="@+id/roster_size_spinner" />

</RelativeLayout>    

</ScrollView>

Here is the Layout I use for the children of the ExpandedListView

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >


<EditText
   android:id="@+id/settingEditText"
   android:layout_width="40dp"
   android:layout_height="wrap_content"
   android:inputType="numberDecimal"
   android:maxLength="3"
   android:paddingLeft="6dp"
   android:paddingRight="6dp"
   android:text="6.0" />

<TextView
    android:id="@+id/settingLabel"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium" />

</LinearLayout>

And here is the Java code for the activity

public class NewLeagueActivity extends Activity{

@Override
public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.new_league);
    setUpUI();

}

public void setUpUI(){

    //Sets up the # of players in league spinner
    Spinner numPlayersSpinner = (Spinner)findViewById(R.id.num_players_spinner);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.num_players, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    numPlayersSpinner.setAdapter(adapter);
    numPlayersSpinner.setSelection(2);

    //Sets up the max roster size spinner
    Spinner rosterSizeSpinner = (Spinner)findViewById(R.id.roster_size_spinner);
    ArrayAdapter adapter2 = ArrayAdapter.createFromResource(this, R.array.roster_size, android.R.layout.simple_spinner_item);
    adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    rosterSizeSpinner.setAdapter(adapter2);
    rosterSizeSpinner.setSelection(2);

    //Sets up the expandable listview for Passing settings
    ExpandableListView passScoring = (ExpandableListView)findViewById(R.id.scoring_settings_list);
    passScoring.setAdapter(new EditScoringAdapter());

}

public class EditScoringAdapter extends BaseExpandableListAdapter {
    private String[] groups = { "Score Settings for Passing", "Score Settings for Rushing",
            "Score Settings for Receiving", "Score Settings for Kicking", "Score Settings for Defense", "Score Settings for Special Teams" };
    private String[][] children = {
            { "Points per Passing Touchdown", "Passing Yards per Point", "Points per Interception Thrown" },
            { "Points per Rushing Touchdown", "Rushing Yards per Point", "Points per Fumble" },
            { "Points per Receiving Touchdown", "Receiving Yards per Point", "Points per Reception" },
            { "Points per PAT", "Points per Field Goal (0-39 yds)", "Points per Field Goal (40-49 yds)", "Points per Field Goal (50+ yds)" },
            { "Points per Interception", "Points per Fumble Recovery", "Points per Sack", "Points per Safety", "Points per Defensive Touchdown",
                "Points per Blocked Kick", "Points for Allowing 0 Points", "Points for Allowing 1-6 Points",
                "Points for Allowing 7-13 Points", "Points for Allowing 14-17 Points", "Points for Allowing 18-21 Points",
                "Points for Allowing 22-27 Points", "Points for Allowing 35-45 Points", "Points for Allowing 46+ Points"},
            {}
    };

    @Override
    public Object getChild(int groupPosition, int childPosition) {
        return children[groupPosition][childPosition];
    }

    @Override
    public long getChildId(int groupPosition, int childPosition) {
        return childPosition;
    }

    @Override
    public View getChildView(int groupPosition, int childPosition,
            boolean isLastChild, View convertView, ViewGroup parent) {
        LayoutInflater inflater = NewLeagueActivity.this.getLayoutInflater();
        View editTextView = inflater.inflate(R.layout.labeled_edit_text, null);
        ((TextView)editTextView.findViewById(R.id.settingLabel)).setText(getChild(groupPosition, childPosition).toString());
        return editTextView;
    }

    @Override
    public int getChildrenCount(int groupPosition) {
        return children[groupPosition].length;
    }

    @Override
    public Object getGroup(int groupPosition) {
        return groups[groupPosition];
    }

    @Override
    public int getGroupCount() {
        return groups.length;
    }

    @Override
    public long getGroupId(int groupPosition) {
        return groupPosition;
    }

    @Override
    public View getGroupView(int groupPosition, boolean isExpanded,
            View convertView, ViewGroup parent) {
        TextView textView = getGenericView();
        textView.setText(getGroup(groupPosition).toString());
        return textView;
    }

    @Override
    public boolean hasStableIds() {
        return true;
    }

    @Override
    public boolean isChildSelectable(int groupPosition, int childPosition) {
        return false;
    }

    public TextView getGenericView() {
        //Layout parameters for the ExpandableListView
        AbsListView.LayoutParams lp = new AbsListView.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, 64);

        TextView textView = new TextView(NewLeagueActivity.this);
        textView.setLayoutParams(lp);
        // Center the text vertically
        textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
        // Set the text starting position
        textView.setPadding(75, 0, 0, 0);
        return textView;

    }

}

}

  • 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-29T04:36:27+00:00Added an answer on May 29, 2026 at 4:36 am

    Remove ScrollView. It’s supposedly not a good practice to nest ListView in a ScrollView and/or vice versa. See this for more details.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am writing an app with both english and french support. The app requests
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I am using Paperclip to handle profile photo uploads in my app. They upload
I'm making a simple page using Google Maps API 3. My first. One marker
I have a jquery bug and I've been looking for hours now, I can't

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.