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

  • SEARCH
  • Home
  • 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 8040255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:50:17+00:00 2026-06-05T03:50:17+00:00

This is my custom layout which was same as android linear layout public class

  • 0

This is my custom layout which was same as android linear layout

public class Custom_TopField extends VerticalFieldManager {
    private static final int FIELD_HEIGHT = 70;

    private String _text;

    Custom_TopField(int color, String text) {
        super(Manager.NO_VERTICAL_SCROLL);
        _text = text;

        Background background = BackgroundFactory.createSolidBackground(color);
        setBackground(background);
    }

    protected void sublayout(int width, int height) {
        width = Math.min(width, getPreferredWidth());
        height = Math.min(height, getPreferredHeight());
        setExtent(width, height);
    }

    public int getPreferredHeight() {
        return FIELD_HEIGHT;
    }

    public int getPreferredWidth() {
        return Display.getWidth();
    }

    public void paint(Graphics graphics) {
        int rectHeight = getPreferredHeight();
        int rectWidth = getPreferredWidth();

        Font font = Font.getDefault().derive(Font.BOLD, 65);
        graphics.drawRect(0, 0, rectWidth, rectHeight);
        graphics.drawText(_text, rectWidth / 2, 10);
        graphics.setFont(font);
        graphics.setColor(Color.WHITE);
        super.paint(graphics);
    }
}

Output = background red and font = black

What I want is background red, font white, font size 40.

I also want to know how to create widget programmatically?

  • 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-06-05T03:50:19+00:00Added an answer on June 5, 2026 at 3:50 am

    To set the font to white and the size to 40 change the paint as follows:

    public void paint(Graphics graphics) {
        int rectHeight = getPreferredHeight();
        int rectWidth = getPreferredWidth();
    
        Font font = Font.getDefault().derive(Font.BOLD, 40);
        graphics.setColor(Color.WHITE);
        graphics.setFont(font);
        graphics.drawRect(0, 0, rectWidth, rectHeight);
        graphics.drawText(_text, rectWidth / 2, 10);
        super.paint(graphics);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a custom tab layout which look like this,I want to make
I have created a custom layout which extends ViewGroup. Everything is working fine and
I have a ListView which contains custom rows. This custom row has following UI
I am leaking memory on this: my custom class: + (id)vectorWithX:(float)dimx Y:(float)dimy{ return [[[Vector
I have a Tab that has a custom layout which contains a TextView .
I have a grid view which is populated using a custom ImageAdapter class extending
Hi i have a linear layout and i want to show my custom view
Ok so I have a layout which looks something like this: LinearLayout TextView LinearLayout
Here is my code: chartDialog = new Dialog(item_activity.this); chartDialog.setContentView(R.layout.customlayout); chartDialog.setTitle(Title ); TextView textItemDetailsDialog =
I'm working on this custom select menu that is part of a forms plugin

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.