ImageButton in Android with transparent background [duplicate] - android

This question already has answers here:
How to have a transparent ImageButton: Android
(23 answers)
Closed 2 years ago.
I have follow this post to make ImageButton in android
android image button
The image appears to the button but it has some background , my Image is a png image and I want the button to be transparent background
any one help please

add this line to your ImageButton xml layout.
android:background="#null"

Here's an alternative solution that worked for me:
android:background="#android:color/transparent"
As Sunny said, add it to the ImageButtons' XML layout

In your code use this:
ImageButton btn = new ImageButton(this);
btn.setImageResource(R.drawable.btn_close);
btn.setBackgroundResource(0);

I don't know if there is any method to do that, but you can paint completely transparent .png file and use method setBackGroundResource() or in XML using this : android:background

By this way you can set transparent background to ImageButton:
<ImageButton android:id="#+id/imagebutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/<imageresourcename>"
android:background="#null"></ImageButton>

Related

Floating Action Button colour [duplicate]

This question already has answers here:
Set FAB icon color
(18 answers)
Closed 4 years ago.
I am using one of the preset button designs (an add button) for my FAB. I was able to change the colour of the background colour of the button but the plus is green and I want to change that. How can I change that?
Using
android:tint
property you can set the color like this
<android.support.design.widget.FloatingActionButton
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:tint="#android:color/white"
android:src="#android:drawable/ic_input_add" />
Hope this helps. Good luck :)

How to add dyanmic circular borders to imageview like whatsapp [duplicate]

This question already has answers here:
How to represent circle border with multiple colors in android
(3 answers)
Closed 5 years ago.
Please guide me to add dynamic dotted border to image view like whatsapp doing in status screen, Kindly see the below image, I circled the functionality of that I want to achieve,
Whatsapp Status Screen
You can try CircularImageView. You can dynamically change borders. Maybe you'il have to make some arrangements. You can look at example project.
Example.
<com.mikhaellopez.circularimageview.CircularImageView
android:layout_width="250dp"
android:layout_height="250dp"
android:src="#drawable/image"
app:civ_border_color="#EEEEEE"
app:civ_border_width="4dp"
app:civ_shadow="true"
app:civ_shadow_radius="10"
app:civ_shadow_color="#8BC34A"/>

Make buttons work [duplicate]

This question already has answers here:
Button background as transparent
(15 answers)
Closed 6 years ago.
How do I add a button on a background image in Android?
I already added the background now I want to add a button and make it work within the background. I have tried to add multiple buttons but then they all don't work, I'm not sure if its the layout or something else.
This is what I have so far:
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="back"
android:id="#+id/button2"
android:layout_alignTop="#+id/button"
android:background="#drawable/scan1"
android:layout_centerHorizontal="true"
android:layout_alignParentStart="false"
android:layout_alignParentLeft="false" />
i edited the code, so the "scan1" drawable is showing red.
Use FancyButtons library to create buttons with transparent background. Set fb_defaultColor param as follows:
fancy:fb_defaultColor="#android:color/transparent"
Using this library, you won't lose ripple effects on button clicks.
You may also use: in your xml:
android:background="#null"
or in code:
button.setBackgroundColor(Color.TRANSPARENT);
Transparent button
android:background="#null"
or
android:background="#android:color/transparent"
android:background="?android:attr/selectableItemBackground"
Add this to your button xml.. Hope it helps

ImageButton Border Transparancy - Removing the square border around round image is not working?

Hello Guys I need some help in creating Imagebutton. I created custom button on PS and then saved it in PNG format with transparent background. After that i patched my image with 9patch. Now i am using that image as a button in my layout but the image is showing colored background corners. I tried alot of things but its not removing.
Here is my XML
<ImageButton
android:id="#+id/mybutton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
android:src="#drawable/registerbutton"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginBottom="123dp" />
Keep the background attribute as #null like this :
android:background="#null"
If still you are getting that corner, it might be from the png file that you are using.
This is an example of what i get from #null
Probably the ouput of "9patching" operation added corners. Open the file and check if there are corners or not.
If that won' help, try switching android:src attribute with android:background attribute.
And u can make .png button online using this site

Android Eclipse how to add an image button with text [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How do I use a compound drawable instead of a LinearLayout that contains an ImageView and a TextView
I currently just have just a button with text in it but now I want to add a background image to it. But I don't want the background image to cover the whole button. I would like it to look something like the buttons in this picture. (Look at the picture under the app screenshots, it's the first image.) Here is a link to the picture.
https://play.google.com/store/apps/details?id=com.pxstudios.minecraftpro&feature=related_apps#?t=W251bGwsMSwxLDEwOSwiY29tLnB4c3R1ZGlvcy5taW5lY3JhZnRwcm8iXQ..
You mean the list view with the text to the right of the buttons? You use two views, a text view and an image view
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<ImageView ...>
<TextView ...>
</LinearLayout>
You can do something like this:
<Button
android:id="#+id/button_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/[your_image]"
android:text="Your_Text"
android:textSize="48dp" //<==give a dimension to a text
android:textStyle="bold"//<==is better your text is bold
/>
If u use Eclipse, use graphic editor to create how many buttons you wants, just copy and paste in your Xml file. And use Strings.xml to store your text.
You can use android:drawableLeft attribute to set the icon to the left. Button is derived from TextView so it supports this attribute,

Categories

Resources