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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:08:23+00:00 2026-06-04T03:08:23+00:00

I create button in xml file like this: <Button android:id=@+id/call_button android:layout_width=match_parent android:layout_height=0dp android:layout_marginTop=30dp android:background=@drawable/button

  • 0

I create button in xml file like this:

    <Button
        android:id="@+id/call_button"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_marginTop="30dp"
        android:background="@drawable/button"
        android:layout_weight="40" 
        android:drawableLeft="@drawable/symbol_phone"
        android:paddingLeft="20dp"
        android:drawablePadding="-25dp"
        android:text="Call"
        android:textColor="@color/white"
        />

I would like to know how I can do drawableLeft in activity. I know that is stupid but I need do this in activity because I create button there. How I can do the same what I have in xml file in my activity? I need add drawableLeft and drawable padding and padding left.
This is how I create button in activity

 Button button1 = new Button(this);
 button1.setLayoutParams(new RelativeLayout.LayoutParams(buttonWidth, buttonHeight));
 button1.setText(systemTexts.getShowCallButton());
 button1.setBackgroundDrawable(new                                      
 button1.setTextColor(Color.parseColor(buttonTextColor));
  • 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-04T03:08:24+00:00Added an answer on June 4, 2026 at 3:08 am
    Drawable image = getContext().getResources().getDrawable( R.drawable.icon );
    image.setBounds( 0, 0, 60, 60 );
    button.setCompoundDrawables( image, null, null, null );
    

    do this

    Update:

    Since getContext().getResources().getDrawable is now deprecated, use this instead:

      Drawable image = ContextCompat.getDrawable(getApplicationContext(),R.drawable.icon);
      image.setBounds( 0, 0, 60, 60 );
      button.setCompoundDrawables( image, null, null, null );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one ImageButton in my xml layout like that : <ImageButton android:id=@+id/tabsButton android:background=@drawable/button
My layout.xml file looks like this: <ScrollView xmlns:android=http://schemas.android.com/apk/res/android android:id=@+id/scrollView1 android:layout_width=fill_parent android:layout_height=270dp android:layout_weight=0.47 > <LinearLayout
I've create an xml file from a csv file like this private void button2_Click(object
I created a field of buttons in my XML file: <RelativeLayout...> <Button android:id=@+id/button_1 ...
I have a main activity with this layout file: <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android
I want to create xml file. I have three text fields and one button
On Android, I would like to create a button that contains some other Views.
I created a state-list selector file item_bg_selector.xml in the drawable folder like this :
I want to create a Button otherthan creating it from xml layout.i want to
i want to create a button which works like a real back button.When 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.