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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T03:26:18+00:00 2026-05-21T03:26:18+00:00

In the below snippet, how could I get mClickable to be the same height

  • 0

In the below snippet, how could I get mClickable to be the same height as mTextArea?

public class EditSpinner extends LinearLayout {

    EditText mTextArea;
    ImageButton mClickable;

    public EditSpinner(Context context, String[] options) {
        super(context);
        setOrientation(HORIZONTAL);
        setGravity(Gravity.CENTER_VERTICAL);
        setBackgroundResource(android.R.drawable.edit_text);
        setAddStatesFromChildren(true);
        setPadding(0, 0, 0, 0);

        mTextArea = new EditText(context);
        mTextArea.setSingleLine(true);
        mTextArea.setBackgroundResource(0);
        addView(mTextArea, new LayoutParams( 
                LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1.0f));   

        mClickable = new ImageButton(context);
        mClickable.setBackgroundResource(0);
        mClickable.setImageDrawable(
                context.getResources().getDrawable(
                        android.R.drawable.btn_default_small));
        //Scale to mTextArea.getHeight()... except getHeight doesn't work
        addView(mClickable, 
                new LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
    }
}
  • 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-21T03:26:19+00:00Added an answer on May 21, 2026 at 3:26 am

    Its a bit difficult to tell exactly what you want, but it sounds like you are asking for two different things, which (generally) isn’t possible with only one layout. Basically from what I interpret, you are saying I want the button to be the same size as the image, and then saying I don’t want the button to be the same size as the image (when its too big).

    My suggestion is to incorporate a way to decipher which layout style you want. Perhaps it is by checking the image size vs the current screen size. Then apply the type of parameters that will work for that particular layout.

    Setting the two the same size is easy via use of the XML android:layout_weight parameter, and you are already familiar with wrap_content for use with a larger image. While you can use these two parameters together you won’t get what you want in all cases (again assuming I understand your post). You’ll need one layout using weights to make the views the same size and another using wrap_content to allow for different sizes.

    Also, just a side note, I would really recommend using XML for layouts unless there is something specific you can’t accomplish with XML.

    Edit: Here is an example for you.

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >
    
        <Button
            android:id="@+id/button_1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="short" />
    
        <Button
            android:id="@+id/button_2"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="medium" />
    
        <Button
            android:id="@+id/button_3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="loooooooooong" />     
    </LinearLayout>
    

    enter image description here

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

Sidebar

Related Questions

I am trying to get the below code snippet to compile. But it fails
I have wrote a class (a snippet is below) which have some data members
I have below snippet of code in which TestClass is extending jPanel which is
//I have created below snippet to let the sensor to be detected. -(void)addProximitySensorControl {
i am working on struts2-jquery plugin . the below snippet is working fine in
The snippet below is generating weird output: for s in servers: vo = ss.getServerVO(s)
Using the snippet below, I've attempted to extract the text data from this PDF
In the code snippet below, from my jQuery setup, I need to check if
In the code snippet below, I am trying to persist two entities - Account
I have below code snippet SimpleDateFormat dateFormat = new SimpleDateFormat( yyyy-MM-dd hh:mm:ss.SSS); String processedContentDate=2012-04-10

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.