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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:29:04+00:00 2026-06-11T16:29:04+00:00

I have to draw a custom view below A banner for that like the

  • 0

I have to draw a custom view below A banner for that like the pick attached PICK

below DaTTab banner I have to draw the Rectangle view my xml

  1. main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/relative_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

  <include android:id="@+id/banner" layout="@layout/upper_border" />

<com.example.ui_1.Border_Portrait
        android:id="@+id/custom_display_view1"
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/banner" 
        />

Draw_Border.jav

class Border_Portrait extends View{
     private static final int DEFAULT_SIZE = 100;

     int mViewHeight , mViewWidth ;
     Paint mPaint ;
     Canvas mCanvas ;
     int margin ;
     float [] mPoints ;
     int mLogoHeight ;
     int mLogoWidth ;
     int dy,dx ;

    public Border_Portrait(Context context) {
        super(context);

    }
    public Border_Portrait(Context context, AttributeSet attrs) {
        super(context, attrs);
        margin = 7 ;
        mPaint = new Paint();
        mPaint.setColor(Color.rgb(0,188,226));  
        mPaint.setStrokeWidth(3);
        mLogoHeight = ScreenUtils.convertDIPToPixels(getContext(), 50 + margin );
        mLogoWidth = ScreenUtils.convertDIPToPixels(getContext(), 66 + margin); 
        dy = ScreenUtils.convertDIPToPixels(getContext(),1) ;
        dx= ScreenUtils.convertDIPToPixels(getContext(),1) ;
    }

    @Override
    protected void onDraw(Canvas canvas) {
        // TODO Auto-generated method stub
        super.onDraw(canvas);
        canvas.save();

        mPoints  = new float [] { 
                    margin + mLogoWidth ,margin,//1
                    getWidth()-margin ,margin ,//1
                    getWidth()-margin ,margin ,//2      
                    getWidth()-margin , getHeight()-margin ,//2 
                    getWidth()-margin , getHeight()-margin  , //3
                    margin , getHeight()-margin , //3
                    margin , getHeight() - margin , //4 
                    margin , mLogoHeight + dy ,//4
                    margin , mLogoHeight + dy , // 5
                    margin + mLogoWidth + dx ,mLogoHeight + dy, //5
                    margin + mLogoWidth ,mLogoHeight + dy, //6
                    margin + mLogoWidth ,margin, //6
                    } ;
        canvas.drawLines(mPoints, mPaint);
        canvas.restore();
    }
    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);

        int parentWidth = MeasureSpec.getSize(widthMeasureSpec);
        int parentHeight = MeasureSpec.getSize(heightMeasureSpec);
        this.setMeasuredDimension(parentWidth, parentHeight);
    }

    private int calculateMeasure(int measureSpec) {
        return 0 ;
    }

}

my question is how to measure the Width of the border at run time I have refer

THIS

and other links too but till now no luck

  • 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-11T16:29:05+00:00Added an answer on June 11, 2026 at 4:29 pm

    Just got the answer add margin in main.xml

    <com.example.ui_1.Border_Portrait
            android:id="@+id/custom_display_view1"
            android:layout_marginTop="50dp"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some custom table view cells that takes a while to draw, so
I have a custom view in my app that I draw using the onDraw()
I have a JPanel that implements custom drawing to draw a background. Over this,
I have a custom view called DrawView created in the main activity. I have
I have a custom view that fills my entire screen. (A piano keyboard) When
I have a UIScrollView with a custom content view that uses drawRect to display
I have a custom View which I draw on bitmaps in the onDraw function.
I have a custom view subclassed from GridView that I use in order to
I have a custom UIView that draws an image in the draw rect method.
I have a map custom view that inherit from MKOverlayPathView. I need this custom

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.