imagebutton

Change viewpager fragment by a buttonClick

倖福魔咒の 提交于 2019-11-30 07:18:59
I'm trying to change the viewpager fragment by clicking on a button. I have 5 fragments, each fragment has it's own xml file (frag1.xml, frag2.xml, and so on). Every fragment has it's 5 buttons that should go to other pages of the viewpager. But the problem is how do I check in the FragmentPageAdapter which button is clicked and how to get there? I'll show the code I have then it should be clear I think. Think of it like a homescreen that has dots at the bottom and I you click a certain dot, you'll go to the corresponding screen. FragmentPagerAdapter public class MyFragmentPagerAdapter extends

Set the text in ImageButton

时光怂恿深爱的人放手 提交于 2019-11-30 04:05:07
问题 I have a ImageButton which looks like this. <ImageButton android:id="@+id/ImageButton" android:layout_width="200dp" android:layout_height="200dp" android:layout_gravity="center" android:layout_marginBottom="6px" android:layout_marginRight="3px" android:layout_toRightOf="@+id/Logo" android:background="@drawable/button_bg_purple" android:scaleType="fitStart" android:src="@drawable/ImageButton" /> ImageButton ImgButton= (ImageButton) this.findViewById(R.id.ImageButton); Now I need to add a

Transparent background in ImageButton with ripple effect?

六眼飞鱼酱① 提交于 2019-11-30 01:48:17
I want to programmatically remove the grey background in ImageButton. I tried many method of removing it like - imageButton.setBackgroundDrawable(null); but on implementing them, I don't get the ripple effect on the ImageButton on touch. (No highlighting on touch). Is there any way to remove the background but preserve the ripple effect or highlight. Mohib Irshad If android:background="?attr/selectableItemBackground" this works than I believe this answer should solve your problem: https://stackoverflow.com/a/28087443/2534007 Create your own RippleDrawable and you need to use mask for the

How to set transparent background for Image Button in code?

我与影子孤独终老i 提交于 2019-11-30 01:39:40
I can set ImageButton background transparent in layout.xml using: android:background="@android:color/transparent" How I can acomplish same thing using java code? Something like ib.setBackgroundColor(???); Parag Chauhan This is the simple only you have to set background color as transparent ImageButton btn=(ImageButton)findViewById(R.id.ImageButton01); btn.setBackgroundColor(Color.TRANSPARENT); bsautner Do it in your xml <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/imageButtonSettings" android:layout_gravity="right|bottom" android:src="

Padding not working on ImageButton

江枫思渺然 提交于 2019-11-30 01:13:28
In an app I am working on, I have several ImageButtons. Each ImageButton has a background and content in the form of a drawable. Right now the drawable is at maximum size within the confines of the ImageButton, but I want it to scale down so I need to add some padding. The thing is that when I try to do that, it doesn't have any effect. My XML is as follows for each ImageButton: <ImageButton android:id="@+id/button_zero" android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="1" android:padding="10dip" android:src="@drawable/button_zero" android:background="

Screen Compatibility issue in android

浪子不回头ぞ 提交于 2019-11-29 22:59:40
问题 I have a problem regarding my app.I have created tab bar using image button,when I run the app in 480*800 hdpi device the tab bar images are displaying perfectly when I run in 240*320 device the images in image button are not displaying properly.I have created the drawable folders and added the images also drawable drawable-hdpi drawable-ldpi drawable-mdpi drawable-xhdpi 回答1: Try following scenario of layout. I found at http://jamil.fluidsoul.net/2011/03/06/creating-android-applications-for

Apply Material Design Touch Ripple to ImageButton?

无人久伴 提交于 2019-11-29 20:14:07
I have an imagebutton that doesn't respond with a touch animation when it is clicked because it is a static image unlike regular buttons on lollipop which come with the built in ripple effect. I would like to add the material design ripple touch effect to the image but can't seem to find a way to implement it. I can set a color filter over the image but that is not the ripple effect. An example of what I'm trying to do is when you hold an album cover image in Google Play Music and a shadow ripple moves across the image. For even better result: <ImageButton android:layout_width="wrap_content"

ListView + ImageButton + descendantFocusability

我的未来我决定 提交于 2019-11-29 18:12:02
I have a listview to which I add rows with 1 imagebutton .. I tried to set the imagebutton the setfocusable false but still not working .. item_list.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="160dp" android:descendantFocusability="blocksDescendants" android:id="@+id/RL_item"> <ImageButton android:layout_width="200dp" android:layout_height="fill_parent" android:id="@+id/imageButton" android:layout_alignParentTop="true" android:layout_alignParentLeft="true" android

Creating irregular shaped ImageButton with different click states

≯℡__Kan透↙ 提交于 2019-11-29 14:42:23
问题 I created an ImageButton with a selector for pressed and non-pressed states, and this works fine. But the button has an irregular shape and I only want it clickable where the underlying rectangular image is non-transparent. So I implemented an OnTouchListener that checks the touch event's co-ordinates against the Bitmap's pixel values (as described in the first answer here: link). This works, in terms of the logic deciding if the button was pressed, but now the image of the button doesn't

Android Drawing bitmap and button on canvas by X Y Positions

落花浮王杯 提交于 2019-11-29 12:51:47
i'm new into android and i have some problems with my app. Any help will be appreciated :) I have drawing bitmap on canvas by xpositon and ypostion by sensors (when i'm moving my phone, bitmaps are moving ) I need to create moving clickable button on center of my bitmaps and when i click them i will go to next activity . Bitmaps are drawing perfectly but idont know how to draw buttons on them, buttons that will be moving with my bitmap by the same values of x and y. How i can do that? This is my piece of code: private void updateBall() { // Calculate new speed // xVelocity += (xAcceleration *