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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:23:27+00:00 2026-06-18T08:23:27+00:00

i am designing for the button using the icon samples, and wish that when

  • 0

i am designing for the button using the icon samples, and wish that when icon is not pressed, it is black, and become white when it is pressed. Coding as follows:

in layout xml:

<Button
     android:layout_height="wrap_content"
     android:layout_width="fill_parent"
     android:layout_weight="1"
     android:background="@drawable/icon_new_btn"
     android:scaleType="fitXY"                
     android:id="@+id/newBtn" />

in icon_new_btn.xml:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:state_pressed="true" >         
        <shape xmlns:android="http://schemas.android.com/apk/res/android"> 
            <solid android:drawableTop="@drawable/icon_new_white"
                android:background="@android:color/transparent"/>> 
        </shape>    
    </item>

    <item>
        <shape xmlns:android="http://schemas.android.com/apk/res/android">            
            <solid android:drawableTop="@drawable/icon_new"
                android:background="@android:color/transparent"/>                        
        </shape>
    </item>

</selector>

Question1 (seem to be solved using the below modification):

The whole button becomes invisible on the screen (it can still be pressed at that screen location!). How could I modify the above coding for meeting the purposes defined? Thanks!!

Modification but new Question (Question2):

The following modified layout and selector seem to be solving the above Question 1. Yet the resolution become much poorer and icon distorted and looks bigger. See the below screenshot for the first and second icon using the below modified codes (icon 3 to 6 are simply using android:drawableTop="@drawable/icon_save" without any pressing effect and showing higher resolution):

enter image description here

modified layout

    <Button
            android:layout_height="wrap_content"
            android:layout_width="fill_parent"
            android:layout_weight="1"
            android:background="@drawable/icon_new_btn"
            android:scaleType="fitXY"                
            android:id="@+id/newBtn" /> 

modified selector:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@drawable/icon_new_white"
          android:state_pressed="true" />    

    <item android:drawable="@drawable/icon_new" />
</selector>
  • 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-18T08:23:28+00:00Added an answer on June 18, 2026 at 8:23 am

    The reason your graphic is being distored is because it being set as the background. To resolve this, you can instead use an ImageButton:

    <ImageButton
            android:layout_height="wrap_content"
            android:layout_width="fill_parent"
            android:layout_weight="1"
            android:src="@drawable/icon_new_btn"
            android:background="@null"
            android:id="@+id/newBtn" /> 
    

    Also, you had specified android:scaleType="fitXY". You might instead want android:scaleType="centerInside".

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

Sidebar

Related Questions

I am designing a custom button with that requires me to overlay a UIButton
I'm designing using IB a specific button (with some labels,and imageView and other stuff).
I'm designing a rather long form that will auto-save every couple minutes (i.e., using
I'm using the UISearchBar (but not the SearchDisplayController that's typically used in conjunction) and
When designing a form I have the option of putting a close button at
I am currently designing GUI for an application using Swing. If you take a
Is it incorrect to use the html <button> tag when designing a UI rather
I am designing an iOS app using XCode 4.2's storyboard feature. The app has
I am designing a set-up wizard using MFC application controls... how do I move
I am using web.py framework for designing a small web application, presently i have

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.