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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:23:27+00:00 2026-05-16T14:23:27+00:00

I made an application that uses a ListAdapter to display some items. In my

  • 0

I made an application that uses a ListAdapter to display some items. In my getView method I use LinearLayout#setPadding() to define the indention of each view depending of some object specific states.

This worked fine in Android 1.5. Last week I decided to move to 1.6 since it’s better suitable for different screen sizes. It all worked fine, but the ListAdapter looks really weird now. The padding isn’t working correctly anymore.

Does anybody know if there is a difference in the ListAdapter or setPadding implementation between Android 1.5 and Android 1.6?

===EDIT: Code added===

@Override
        public View getView(int position, View convertView, ViewGroup parent) {
            TextView text = (TextView) View.inflate(lexs, R.layout.law_list_book_view, null);

            if (items.get(position) instanceof Chapter) {
                LinearLayout chapterView = new LinearLayout(lexs);
                chapterView.setOrientation(LinearLayout.HORIZONTAL);
                chapterView.setGravity(Gravity.CENTER);

                ImageView img = new ImageView(lexs);
                img.setPadding(0, 0, 5, 0);
                chapterView.addView(img);

                chapterView.addView(text);
                text.setTextColor(Color.BLACK);
                text.setText((CharSequence) items.get(position).getName() + ": " + ((Chapter) items.get(position)).getTitle());
                text.setMinWidth(320);
                switch (((Chapter) items.get(position)).getLevel()) {
                    case 0:
                        text.setTextColor(Color.rgb(0, 0, 0));
                        break;
                    case 1:
                        text.setTextColor(Color.rgb(50, 50, 50));
                        chapterView.setPadding(10, 0, 0, 0);
                        break;
                    case 2:
                        text.setTextColor(Color.rgb(100, 100, 100));
                        chapterView.setPadding(20, 0, 0, 0);
                        break;
                    case 3:
                        text.setTextColor(Color.rgb(150, 150, 150));
                        chapterView.setPadding(30, 0, 0, 0);
                        break;
                    case 4:
                        text.setTextColor(Color.rgb(175, 175, 175));
                        chapterView.setPadding(40, 0, 0, 0);
                        break;
                    default:
                        text.setTextColor(Color.rgb(200, 200, 200));
                        chapterView.setPadding(50, 0, 0, 0);
                        break;
                }

                if (((Chapter) items.get(position)).isExpanded()) {
                    img.setImageResource(R.drawable.minus);
                } else {
                    img.setImageResource(R.drawable.plus);
                }

                if (((Chapter) items.get(position)).isSearched()) {
                    text.setBackgroundColor(Color.MAGENTA);
                }
                text.setTextSize(15);
                return chapterView;
            } else {
                LinearLayout paragraphView = new LinearLayout(lexs);
                paragraphView.setOrientation(LinearLayout.HORIZONTAL);
                paragraphView.setGravity(Gravity.CENTER);
                paragraphView.setPadding( (((Chapter) ((Paragraph) items.get(position)).getRoot()).getLevel() * 10) + 15 + 8 , 0, 0, 0);

                DisplayMetrics metrics = new DisplayMetrics();
                lexs.getWindowManager().getDefaultDisplay().getMetrics(metrics);

                ImageView paragraphImg = new ImageView(lexs);
                paragraphImg.setImageResource(R.drawable.paragraph);
                paragraphView.addView(paragraphImg);

                LinearLayout textLayer = new LinearLayout(lexs);
                textLayer.setGravity(Gravity.LEFT);
                textLayer.setMinimumWidth(metrics.widthPixels / 2);
                text.setTextColor(Color.BLACK);
                textLayer.addView(text);
                textLayer.setOnClickListener(new BookViewOnClickListener(position));
                paragraphView.addView(textLayer);
                text.setText("Artikel " + (CharSequence) items.get(position).getName());

                LinearLayout buttonLayer = new LinearLayout(lexs);
                buttonLayer.setGravity(Gravity.RIGHT);
                ImageButton mark = new ImageButton(lexs);
                if (WorkspaceView.createView(lexs).isFavorite((Paragraph) items.get(position))) {
                    mark.setBackgroundResource(R.drawable.article_not_favorite);
                } else {
                    mark.setBackgroundResource(R.drawable.article_favorit);
                }
                mark.setOnClickListener(new BookViewOnClickListener(position));
                buttonLayer.addView(mark);
                buttonLayer.setPadding(0, 0, 10, 0);
                buttonLayer.setMinimumWidth(metrics.widthPixels / 2);
                paragraphView.addView(buttonLayer);
                text.setTextSize(15);

                if (((Paragraph) items.elementAt(position)).isSearched()) {
                    text.setBackgroundColor(Color.RED);
                }

                return paragraphView;
            } 

        }

===EDIT 2: Screenshot added===

alt text

I know that this elements of the list are all level 0 elements and should therefore have no padding (I used logcat to verify the level of the elements. they are all 0). the level of the elements i use in the switch case to check the padding (see code)

  • 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-16T14:23:28+00:00Added an answer on May 16, 2026 at 2:23 pm

    You have the API Differences page to check that but honestly I don’t think it’s a SDK issue. Try posting your code so we can reproduce.

    EDIT:
    Screenshot after trying to reproduce the issue:

    alt text

    This looks good, what’s your issue again?

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

Sidebar

Related Questions

I have a .NET application that uses an assembly (.dll) that defines some method:
I have made a web application that uses master page for Login & Logout
I've made an application that makes full use of ajax, and what I need
I have a web application that uses jQuery to load some sound effect on
HP iPAQ 110 Classic Handheld. I made an application that uses windows mobile 6.0
I have made a MVC application that uses the built-in ASP.NET login functions. It
I have made a MDI (tabbed) application that uses PictureBoxes inside TabPages. The picturebox
I have a windows forms application that uses excel to generate some reports. Untill
I've written an application that uses some serial port hardware directly, and abstracted the
I have an asp.net application that uses the file (something like hand-made DB). It

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.