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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:55:49+00:00 2026-06-09T03:55:49+00:00

I have a problem which I don’t know how to solve. I have created

  • 0

I have a problem which I don’t know how to solve. I have created a custom view and would like to align it to parrent buttom in a relative layout but when I do that the view gets transparrent?! How can this be?
Also if I set the surrounding views layout_height = wrap_content it fills the whole screen. How can I configure it not to do so but just wrap content?

Here is my custom view

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Shader;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.RelativeLayout;

public class HomeMenuBackground extends View
{ 
    private int mScreenWidth;
    private int mScreenHeight;
    private RectF mSpace;
    private RectF mSpaceStroke;
    private Paint mPaint;
    private Paint mPaintStroke;
    private Rect mRect; 
    private LinearGradient mGradient;

    public HomeMenuBackground(Context context, AttributeSet attrs)
    {
        super(context, attrs);

        mScreenWidth = context.getResources().getDisplayMetrics().widthPixels;
        mScreenHeight = context.getResources().getDisplayMetrics().heightPixels;
        final int mHeighMenu = (int) (mScreenHeight*0.8);
        mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mSpace = new RectF(-20, 2, mScreenWidth + 20, 148);
        mSpaceStroke = new RectF(-22, 0, mScreenWidth + 22, 150);
        mRect = new Rect();

        mPaintStroke = new Paint();
        mPaintStroke.setStyle(Paint.Style.STROKE);
        mPaintStroke.setStrokeCap(Paint.Cap.ROUND);
        mPaintStroke.setStrokeWidth(2);
        mPaintStroke.setColor(Color.BLACK);
        mPaintStroke = new Paint(Paint.ANTI_ALIAS_FLAG);

    }

    @Override
    public void onDraw(Canvas canvas)
    {       
        mRect.set(0, 75, canvas.getWidth(), canvas.getHeight());
        canvas.drawArc(mSpaceStroke, 180, 360, true, mPaintStroke);
        canvas.drawArc(mSpace, 180, 360, true, mPaint);
        canvas.drawRect(mRect, mPaint);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) 
    {
        if(mGradient == null)
        {
            mGradient = new LinearGradient(0, 0, 0, MeasureSpec.getSize(heightMeasureSpec), Color.WHITE, Color.GRAY, Shader.TileMode.MIRROR);
            mPaint.setShader(mGradient);
        }

        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }
}

I hope you can help me 😀

BR FireFly3000

  • 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-09T03:55:52+00:00Added an answer on June 9, 2026 at 3:55 am

    For deciding the height and width of Custom View you can override setMeasuredDimension (int measuredWidth, int measuredHeight) method and provide the height, width of view as per your requirement. And I tried with RelativeLayout I can see your Layout at the Bottom with height and width of (100, 100) by using setMeasuredDimension(100, 100); inside onMeasure() method.

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

Sidebar

Related Questions

I have a problem which I don't really know how to solve. I have
I have a problem which I don't know how to fix. It has to
there's a problem which I don't know how to solve. I know how to
I am having a strange problem which I don't understand. I have the following
I have another weird problem which I have not been able to solve in
I have a problem which I'm pretty sure that I can't solve without going
I have a problem which I don't understand and there doesn't seem to be
I'm having a problem which I don't know what to search in google. Basically
I have a typical problem which is like the following: 1) I was working
So I have this problem, which I don't see how it's happening. Basically I

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.