android-button

Button with getBackground().setAlpha on version 5 - lollipop isn't working correctly

你离开我真会死。 提交于 2019-12-05 03:36:43
问题 I have this code and works for every version since API 14 but on Android 5.0 (Lollipop) isn't working correctly. Below is the way how I want the buttons appear. click of button1 buttonArrivals.getBackground().setAlpha(180); buttonDepartures.getBackground().setAlpha(255); click of button2 buttonArrivals.getBackground().setAlpha(255); buttonDepartures.getBackground().setAlpha(180); On Lollipop version the buttons appear with the same Alpha but I never set the same alpha. I just use the code

Write Multiline Text on Button in Android

≯℡__Kan透↙ 提交于 2019-12-05 02:39:57
I want to know, How to write Multiline Text on Button <Button android:id="@+id/button1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:layout_marginTop="100dp" android:background="@drawable/layout_border" android:text="Hours Mon - sat 5pm" /> I am getting like this:- but required this kind of button:- Edited::-- Now i got something like this, by using answer given by, @Sino K D : but still looking for help, After adding drawable to left side, getting this:- Sino K D Use (new line)

OnClickListener() must override a superclass method?

ぐ巨炮叔叔 提交于 2019-12-05 02:07:23
With this code: import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; . . . Button buttonAuthorizeUsers = (Button) findViewById(R.id.buttonAuthorizeUsers); buttonAuthorizeUsers.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent configure = new Intent(OnDemandAndAutomatic_Activity.this, Configure_Activity.class); OnDemandAndAutomatic_Activity.this.startActivity(configure); } }); I'm getting: The method onClick(View) of type new

Why does maxWidth on a Button not work and how to work around it?

坚强是说给别人听的谎言 提交于 2019-12-05 00:20:29
I have two buttons on the layout, and on a large-screen device (tablets) I want to cap their width so they don't look ridiculous. I expected to use the maxWidth attribute but it apparently does nothing in my scenario. Here's the layout definition - the buttons use up the full width of the layout, ignoring any value in maxWidth. <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:maxWidth="100dp" android:text="Button 1" />

Setting Button text font in android

无人久伴 提交于 2019-12-04 23:37:56
I have a button created using android widgets. I want to set the font of the button text to Helv Neue 67 Med Cond . How to get this font and set it to the button text in android layout file? First you have to put the ttf file in assets folder and then You can use the below code to set Custom font in TextView, same way you can do for Button: TextView txt = (TextView) findViewById(R.id.custom_font); Typeface font = Typeface.createFromAsset(getAssets(), "Helv Neue 67 Med Cond.ttf"); txt.setTypeface(font); Ann I guess you may have already found the answer, but if not (and for other developers),

Android layout as button with selectable functionality

99封情书 提交于 2019-12-04 17:53:41
问题 I'm trying to create a button-like component, with a left-aligned ImageView and then 2 TextViews to the right of the ImageView, stacked one above the other and formatted differently, like the following example:. __________________________ | | | |-----| Bold Main Text | | |Image| | | |-----| Small Sub Text | |__________________________| I also want the ImageView to change depending on the click state of the outer container, much like a standard button would do with a selectable resource

Disable button with button selector

99封情书 提交于 2019-12-04 16:05:26
问题 I have a button selector that changes the button image when it is pressed. I have also set an image for when the button is disabled. I try and disable the button programmatically but the disabled button image is not appearing. Is my button_selector correct? <item android:drawable="@drawable/red_btn_bg_disabled" android:state_enabled="false"/> <!-- disabled --> <item android:drawable="@drawable/red_btn_bg_pressed" android:state_pressed="true"/> <!-- pressed --> <item android:drawable="

How to properly style material buttons in android

自古美人都是妖i 提交于 2019-12-04 15:04:40
I am going after flat buttons for my example, but the question really applies to all buttons. Why does it seem so hard to find documentation on the proper way to style material buttons in android. I have the following which I messed around with until I could get it to work. Felt like a hack so I am not sure if this is really the right way to do it. <Button android:id="@+id/apply" style="?android:attr/borderlessButtonStyle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/md_cyan_A700" android:text="Cancel"/> So I used 'borderlessButtonStyle' to

How to apply an style to all ImageButtons in Android?

故事扮演 提交于 2019-12-04 14:16:14
I have the following style in my application. <style name="BtnPressed"> <item name="android:background">@drawable/btn_default</item> </style> Now I want to apply that to all the ImageButtons in my application. I tried to use the solution mentioned in this question but it did not work. I'm using API-7. Change your BtnPressed style to this: <style name="BtnPressedStyle" parent="Widget.ImageButton"> <item name="android:background">@drawable/btn_default</item> </style> Define an application-wide theme/style: <style name="MyTheme" parent="android:Theme"> <item name="android:imageButtonStyle">@style

Android: Goto HTTP Url on Button Click

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-04 08:59:03
问题 I want to go to a web page on the click of a button in my Android app. So say, I have a button called "Google", when the user clicks on that button I want google.com to open up on the screen. How is this achieved? Also, is there a way I can gain control back to my app once the user is finished with Google? 回答1: In your activity do something like this. public void openWebURL( String inURL ) { Intent browse = new Intent( Intent.ACTION_VIEW , Uri.parse( inURL ) ); startActivity( browse ); } By