android-button

How to properly remove padding (or margin?) around buttons in Android?

好久不见. 提交于 2019-11-29 23:09:29
Currently, I have the following bottom log in button. When button is not being pressed When button is being pressed The XML looks like this <LinearLayout android:background="?attr/welcomeBottomNavBarBackground" android:orientation="horizontal" android:id="@+id/sign_in_bottom_nav_bar" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true"> <Button style="?android:attr/buttonBarButtonStyle" android:id="@+id/sign_in_button" android:layout_width="0dp" android:width="0dp" android:layout_weight="1.0" android:layout_height="48dp" android

Create a 3d shaped button in android [closed]

我只是一个虾纸丫 提交于 2019-11-29 20:42:21
I was trying to create a button similar in look to the round buttons over here - http://livetools.uiparade.com/index.html (every button looks like it is inside an immersed section) I had it by placing the button in a circle background and giving them both a little gradient that didnt end up the same though I got this result - (I will upload my code once I can) how can I achieve that same look? Try this code. I am able to produce an image that looks like this which is similar to the first button you link to, using the following code. The key is to use <layer-list> to layer shapes one over the

How to set Different String in a Textview in Fragment while clicking different Button?

非 Y 不嫁゛ 提交于 2019-11-29 18:07:19
I'm new to Android app programming. I have two Fragments - fragmentA.xml and fragmentB.xml . In fragmentA there are two Buttons - Button One (id: btnOne ) and Button Two (id: btnTwo ). In fragmentB there is TextView (id- textView ) In fragmentB java class there are two String - string1 and string2 Both buttons refers to fragmentB . I want two set the textView text to string1 when I press Button One and string2 when I press Button Two. How can I do that? I was using following code in fragmentB java class to display only string1 public View onCreateView( LayoutInflater inflater, ViewGroup

what is the best way to do a button group that can be selected and activate independently?

独自空忆成欢 提交于 2019-11-29 17:19:23
问题 I'm trying to do in android a group of buttons that can be selected and activate only one of them. I need to work with the same logic of a radiogroup and radiobuttons. I tried many alternatives but I want the most effective way. How can I do it? 回答1: You can use this simple way : 1.activity_button_group.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"

Custom shape button

笑着哭i 提交于 2019-11-29 16:26:05
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 the blog post the image views are still rectangular, but the bitmaps the blogger was using in the

Events for Long click down and long click up in Android

随声附和 提交于 2019-11-29 11:38:57
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); } public FfwRewButton(Context context) { this(context, null); } public FfwRewButton(Context context,

AppCompatButton backgroundTint API < 21

你离开我真会死。 提交于 2019-11-29 02:52:40
I want to use ripple effects on Buttons. AppCompat v22.1 added AppCompatButton and new functionalities to AppCompat tinting. My Layout: <android.support.v7.widget.AppCompatButton android:id="@+id/add_remove_button" android:layout_width="match_parent" android:layout_height="match_parent" android:backgroundTint="@color/primary" android:textColor="@android:color/white" android:text="Remove" /> On my API 22 test device the ripple effect works perfectly, but i'm coding for API 11 and unfortunately backgroundTint needs API >= 21. How can i set the ripple effect to Buttons on older API versions? Just

how to change size of button dynamic in android

。_饼干妹妹 提交于 2019-11-29 02:45:46
I try setWidth() and setheight() method but it not work Flavio Try using LayoutParams. For example button.setLayoutParams (new LayoutParams(50, LayoutParams.WRAP_CONTENT) For me works perfect this: ViewGroup.LayoutParams params = myButton.getLayoutParams(); //Button new width params.width = 400; myButton.setLayoutParams(params); I found this to be the best solution because it also allows the button to be repositioned at the same time by simply changing its margin: int buttonWidth = (int) (screenWidth / 3.0); RelativeLayout.LayoutParams params = (LayoutParams) myButton.getLayoutParams(); params

How to set Style for a button in Android?

谁都会走 提交于 2019-11-29 01:22:51
I have defined the below files in res folder. styles_apptheme.xml <?xml version="1.0" encoding="utf-8"?> <!-- Generated with http://android-holo-colors.com --> <resources xmlns:android="http://schemas.android.com/apk/res/android"> <style name="ButtonAppTheme" parent="android:Widget.Holo.Light.Button"> <item name="android:background">@drawable/apptheme_btn_default_holo_light</item> </style> </resources> themes_apptheme.xml <?xml version="1.0" encoding="utf-8"?> <!-- Generated with http://android-holo-colors.com --> <resources xmlns:android="http://schemas.android.com/apk/res/android"> <style

In Android, how to make Login button disable with respect to EditText?

北城以北 提交于 2019-11-28 23:24:40
问题 If EditText is empty then Login Button has to be disabled. And if EditText has some texts then Login Button has to be enabled. Well you can see this method on Instagram Login. Both fields are empty, Sign in Button is DISABLED. Here Password field is empty, so still Sign in Button is DISABLED. Here both Username and Password field is not empty, So Sign in Button is ENABLED. how to achieve these steps?? here is my code and it doesn't work.. EditText et1,et2; @Override protected void onCreate