android-button

How can i position a button in between two layouts

ぐ巨炮叔叔 提交于 2019-11-28 11:44:21
I am trying to position a button in between two layouts. Also, I don't want to have to do this with a margin if I can help it, when you start dealing with different screen sizes margin breaks down. (In this image, I am trying to position the green button in between two layouts) <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_height="fill_parent" android:layout_width="fill_parent" android:background="@color/busy_white"> <LinearLayout android:orientation="vertical" android:layout_height=

How to get material icon button in Android?

笑着哭i 提交于 2019-11-28 11:43:55
How can I get a material button in android? I have tried this code but don't know how to include an image like this: <com.google.android.material.button.MaterialButton android:id="@+id/material_button" style="@style/Widget.MaterialComponents.Button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Add to Cart"/> You need Icon style for the Material Button like below: <com.google.android.material.button.MaterialButton style="@style/Widget.MaterialComponents.Button.Icon" android:layout_width="match_parent" android:layout_height="wrap_content" android:text=

Custom shape button

喜夏-厌秋 提交于 2019-11-28 10:51:27
问题 I am trying to make each slice of the pie a button. The pie is a bunch of vector drawables in an image view. I don't necessarily need the actual pie slices to be clicked. I was thinking of using Path to draw a transparent shape and place it on top and make that the button, but from what I understand, drawables aren't clickable. I read one blog post that apparently used paths to make a custom shaped image view, and I know image views are clickable, but it seems like with the implementation in

Listview with Checkbox,RadioButton,Textview and button not working correctly in android

坚强是说给别人听的谎言 提交于 2019-11-28 10:22:29
I am creating a android app the UI of my application is below given. On clicking of submit button, I need the selected check box, and radio buttons value. Example Linux is not checked, cc(radio button) is checked. Records are populated dynamically in list view, but I am not able to make it work. A lot of problems are there. When I scroll the list view radio button gets automatically selected or deselected not able to maintain the state of radio button. On click of button not getting the selected radio button as well as check box. Below is my layout as well as java program. Suggest me to get

Moving buttons via Touch

我怕爱的太早我们不能终老 提交于 2019-11-28 08:49:31
I want to move my buttons to another palce with touch. I mean if user touch one button and go to another place via touch, the button moves. I write this code for one of buttons, but when i touch one button, three button moves as well as and one button cannot move to right or left and when i move to top of screen, a part of image button deleted! What is the problem? and How can i solve this? I want run this program in android +2.2 onButton.setOnTouchListener(new OnTouchListener(){ @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub switch(event

Create Button with rounded corners in android

时光怂恿深爱的人放手 提交于 2019-11-28 08:33:21
I'm trying to create a button which looks as in the image above. Initially my idea was to create a 9 patch and set it as the button background. But since, this is a plain button, i think we can somehow draw this without using any images. The button background color is #0c0c0c The border color is #1a1a1a The text color is #cccccc I found a similar question on SO but that creates a gradient - Android - border for button The Android Developer's Guide has a detailed guide on this: Shape Drawbables . You could also simply remove the gradient element from the link you provided: <shape xmlns:android=

How do I set a different color for the pressed state of the button?

﹥>﹥吖頭↗ 提交于 2019-11-28 08:05:32
I have some Buttons on my android app. They have an icon and text. I can set the background color of a Button in java code. If the button is clicked I want to display with a different color. So, how do I set a different color for the pressed state of the Button ? <Button android:id="@+id/save" android:layout_width="130dip" android:layout_height="wrap_content" android:scaleType="center" android:drawableTop="@drawable/save" android:text="Save" android:textColor="#FFFFFF" android:textSize="14dip" > The onCreate method: public void onCreate(Bundle savedInstanceState) { super.onCreate

Events for Long click down and long click up in Android

我怕爱的太早我们不能终老 提交于 2019-11-28 05:44:13
问题 I want two separate event for long click Down and Long click up. How can I do this in Android? What I have tried is as follows public class FfwRewButton extends ImageButton { public interface ButtonListener { void OnLongClickDown(View v); void OnLongClickUp(View v); } private ButtonListener mListener; private boolean mLongClicked = false; public FfwRewButton(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setFocusable(true); setLongClickable(true); }

setEnabled() vs setClickable(), what is the difference?

ぐ巨炮叔叔 提交于 2019-11-28 05:10:38
Until now, when I wanted to stop the user from pressing the button, I would set the button.setClickable(false); and usually change the text to some kind of grey colour (to let the user know that the button is disabled). Today I stumbled upon the setEnabled() property. So I went to the documentation to see the method's explanation below: setEnabled(boolean enabled) Set the enabled state of this view. What does this even mean? What is the difference between enable state/clickable state and disabled state/not clickable state? Could someone please explain what is the difference between doing what

How to set focus to a button widget programmatically?

隐身守侯 提交于 2019-11-28 04:36:35
Is it possible to set a focus to a button widget which lies somewhere down in my layout? onCreate of the activity my control/focus should be on that button programmatically. Pentium10 Yeah it's possible. Button myBtn = (Button)findViewById(R.id.myButtonId); myBtn.requestFocus(); or in XML <Button ...><requestFocus /></Button> Important Note: The button widget needs to be focusable and focusableInTouchMode . Most widgets are focusable but not focusableInTouchMode by default. So make sure to either set it in code myBtn.setFocusableInTouchMode(true); or in XML android:focusableInTouchMode="true"