android-button

Android Button in Gridlayout don't have same margin top

放肆的年华 提交于 2019-12-11 10:19:50
问题 I got a GridLayout, and there will be two or more buttons in the layout, and all the buttons must with same width. My problem is that when the buttons having different line number of text, the marginTop of button will different too. How can I fix this? Thanks. <GridLayout android:id="@+id/grid_buddies" android:columnCount="4" android:layout_width="match_parent" android:layout_height="wrap_content"> <Button android:layout_width="60dp" android:layout_height="match_parent" android:text="TEST"/>

change toggle button text color through xml

三世轮回 提交于 2019-12-11 09:35:37
问题 Hi i'm trying to change the color of toggle button's text through xml. I have referred links but its only changing the background color of toggle button but not its text. I tried with this approach : <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_checked="true" android:color="#ffffff" /> <item android:state_checked="false" android:color="#000000" /> </selector> but only the background is changing. Note : I don't

Android: MaterialButton override textColor in Style

放肆的年华 提交于 2019-12-11 06:55:42
问题 I want to define an alternative Button Style that uses my secondaryColor as background and the ?colorOnSecondary respectively for the text. But I'm struggling to get the textColor defined in a style. The MaterialButton is using a (private) selector-drawable for the textColor which uses ?colorOnPrimary . So this is cumbersome to override. Is there another way to set the color without the selectorDrawable? 回答1: If you want to override the colors only for the buttons, you can use the

How can i do a “return back” button in Java?

不羁岁月 提交于 2019-12-11 04:45:52
问题 I have an app that counts the score in a basketball match. There are three buttons for each team to increase the score (+3, +2, free throw). I want to create a button to return back in case the user click a button for mistake. Without creating three separate buttons for each score (+3,+2,+1). But i don't really know how to transform this in Java code. Something like: Score=score-lastNumberAdded. Sorry for my english. This is the code: XML <LinearLayout xmlns:android="http://schemas.android

android-button background drawable doesn't work

亡梦爱人 提交于 2019-12-11 03:22:07
问题 this is my xml drawbale code with the name of btntheme.xml : <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/customactionbartheme_btn_default_normal_holo_light" android:state_enabled="true" android:state_window_focused="false"/> <item android:drawable="@drawable/customactionbartheme_btn_default_disabled_holo_light" android:state_enabled="false" android:state_window_focused="false"/> <item android:drawable="@drawable/customactionbartheme

Pass screen coordinates from button to parent

♀尐吖头ヾ 提交于 2019-12-11 03:20:17
问题 I am making a piano app for android. As a sample(test), I have 4 buttons in my activity. The parent is a Relative Layout and I also have a few textviews that tell the screen coordinates of the finger touch. There is one more textView("Entered Button") that detects if your finger is over a button or not This is what it looks like: I achieved this using the code given below. Java public class MainActivity extends Activity { Button b1, b2, b3, b4; int b1x1, b1x2, b1y1, b1y2; private TextView

Android How to change Button Background on OnTouchListener

ぐ巨炮叔叔 提交于 2019-12-11 03:15:44
问题 Hi I have a button in xml, and I am using OnTouchListener in my activity to get button press and release. But the problem is that when I press the button the background color is not changing. Where as when I extend may activity with OnClickListener the background is changing. Can any one tell what wrong with my code. public class pushbuttonActivity extends Activity implements OnTouchListener { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

How to add an item to a ListView with each Button click

无人久伴 提交于 2019-12-11 02:19:27
问题 This is the code I'm working on, it should simply add an item in a ListView (w/ array) each time the Button is clicked. The text inserted by the user on a EditText should be added to the list each time the Button is clicked. I find that this line of code: new Button.OnClickListener() is seen as an 'anonymous' thing, and it's not run, please help me out ;( import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.view.*; import android.widget.*; import java.lang

Use 2 (or more) colors for a button text

*爱你&永不变心* 提交于 2019-12-11 00:01:32
问题 I know I can change the color of the text on a button by the following ways : button.setTextColor(getApplication().getResources().getColor(R.color.red)); //TAKE DEFAULT COLOR or button.setTextColor(0xff0000); //SET CUSTOM COLOR or button.setTextColor(Color.parseColor("#ff0000")); However I want to use two colors for the text : for example, suppose my button has the following text : "Click Here" , I want the "Click" part to appear in red, and the "Here" part in blue. Is this possible ? 回答1:

I want to use Widget.Button.Transparent style with my button

怎甘沉沦 提交于 2019-12-10 21:36:12
问题 error: Error: Resource is not public. (at 'style' with value '@android:style/Widget.Button.Transparent').,style="@android:style/Widget.Button.Transparent" 回答1: I have bad news. The Android API is white-listed. Only object that are listed in $ANDROID_SRC/frameworks/base/api/NN.txt are visible to client applications running on API level NN. While the three other button styles found in styles.xml are all exposed, Widget_Button_Transparent is not. You can't use it. 来源: https://stackoverflow.com