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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:53:49+00:00 2026-06-10T10:53:49+00:00

In my android app, I wanna put a border on a ImageView . I

  • 0

In my android app, I wanna put a border on a ImageView. I don’t know how can put view on another view. Actually border is a custom view.

Custom View Class:

public class CropBorder extends View {

    private Paint paint = new Paint();


    public CropBorder(Context context) {
        super(context);
    }

    public CropBorder(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
    }


    @Override
    public void onDraw(Canvas canvas) {
        float[][] circleXY = {{5, 5}, {155, 5}, {305, 5}, {5, 105}, {155, 105}, {305, 105}, {5, 55}, {305, 55}};
        float[][] lineXY = {{5, 5, 305, 5}, {5, 105, 305, 105}, {5, 5, 5, 105}, {305, 5, 305, 105}};

        paint.setColor(Color.BLACK);
        paint.setStrokeWidth(1);

        for(int i = 0 ; i < circleXY.length ; i++)
            canvas.drawCircle(circleXY[i][0], circleXY[i][1], 5, paint);

        paint.setStrokeWidth(2);

        for(int i = 0 ; i < lineXY.length ; i++)
            canvas.drawLine(lineXY[i][0], lineXY[i][1], lineXY[i][2], lineXY[i][3], paint);
    }

}

Activity Class:

public class CropTestActivity extends Activity {

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

}

Layout XML:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/crop_test_layout"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <com.nvtech.backend.utility.imageEditor.CropBorder
        android:id="@+id/crop_border"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_marginTop="10dp"
        android:layout_marginLeft="10dp" >
    </com.nvtech.backend.utility.imageEditor.CropBorder>

    <ImageView
        android:id="@+id/android_image"
        android:src="@drawable/android"
        android:layout_width="300dp"
        android:layout_height="300dp"
        android:layout_marginTop="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginBottom="10dp"
        android:layout_marginLeft="10dp"
        android:layout_gravity="center"
        android:scaleType="fitXY"
        android:contentDescription="@string/android_image_description" >
    </ImageView>

</LinearLayout>
  • 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-10T10:53:50+00:00Added an answer on June 10, 2026 at 10:53 am

    You can just wrap your ImageView in a LinearLayout, and use the padding to set the border:

    <LinearLayout // this is your root container ... >
        <LinearLayout
            android:id="@+id/content_item_image_wrapper"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="#00FFFFFF"
            android:padding="3dip" >
    
            <ImageView
                android:id="@+id/user_profile_thumbnail"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:adjustViewBounds="true"
                android:maxHeight="80dp"
                android:src="@drawable/ic_launcher" />
        </LinearLayout>
    </LinearLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

import android.app.Activity; import android.os.Bundle; import android.util.Log; import android.widget.Button; public class FileExplorerActivity extends Activity {
i'm programming an android app, a Tasker, and i really don't find the way
Please don't judge me, i'm extremely new on android developing... I wanna make an
My Android app should do the following: The MainActivity launches another thread at the
I wanna create my android app in three languages. English & Punjabi & Gujarai.
I have an app in android in which I wanna achieve the following thing:
Hey experts, actually it's a pretty simple question...just don't know about the answer. I
The android app I am working on overrides the Application class to store lightweight
I'm a android app developer. I wanna remove a specific phone/email history. Android 2.2
This android app Plan B claims that you can install and run it remotely,

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.