android-button

Rounded Button in Android

懵懂的女人 提交于 2019-12-17 07:02:30
问题 I want to create rounded buttons in an Android program. I have looked at How to create EditText with rounded corners? What I want to achieve is: Rounded Edge Buttons Change Button background/appearance on different states (Like Onclick, Focus) Use my own PNG for the background and not create a shape. 回答1: You can do a rounded corner button without resorting to an ImageView. A background selector resource, button_background.xml : <?xml version="1.0" encoding="utf-8" ?> <selector xmlns:android=

Save image to sdcard from drawable resource on Android

[亡魂溺海] 提交于 2019-12-17 03:39:20
问题 I'm wondering how to save an image to user's sdcard through a button click. Could some one show me how to do it. The Image is in .png format and it is stored in the drawable directory. I want to program a button to save that image to the user's sdcard. 回答1: The process of saving a file (which is image in your case) is described here: save-file-to-sd-card Saving image to sdcard from drawble resource: Say you have an image namely ic_launcher in your drawable. Then get a bitmap object from this

Why is my Button text forced to ALL CAPS on Lollipop?

戏子无情 提交于 2019-12-17 02:28:33
问题 In my app "Tide Now WA" which I recently tested for compatibility using the new Nexus 9 tablet (Lollipop - API 21). It writes some button text. This app writes the text correctly using Android 2.3 and Android 4.0. I.e. mixed capital and lower case letters. When same app is run on my Nexus 9 all the letters in the text are capitalized. FWIW my manifest contains the following statement: uses-sdk android:minSdkVersion="10" android:targetSdkVersion="14" Can I fix this in my code or is it a bug in

Coloring Buttons in Android with Material Design and AppCompat

孤街浪徒 提交于 2019-12-17 02:24:52
问题 Before the AppCompat update came out today I was able to change the color of buttons in Android L but not on older versions. After including the new AppCompat update I am unable to change the color for either version, when I do try the button just disappears. Does anyone know how to change the button color? The following pictures shows what I want to achieve: The white button is default, the red one is what I want. This is what I was doing previously to change the color of the buttons in the

Android customized button; changing text color

ⅰ亾dé卋堺 提交于 2019-12-17 01:34:13
问题 I made a button that changes the background drawable on different states, this way: <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@drawable/btn_location_pressed" /> <!-- pressed --> <item android:state_focused="true" android:drawable="@drawable/btn_location_pressed"/> <!-- focused --> <item android:drawable="@drawable/btn_location"/> <!-- default --> The problem here is that I'm also trying to change the textColor as

Android customized button; changing text color

那年仲夏 提交于 2019-12-17 01:34:08
问题 I made a button that changes the background drawable on different states, this way: <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@drawable/btn_location_pressed" /> <!-- pressed --> <item android:state_focused="true" android:drawable="@drawable/btn_location_pressed"/> <!-- focused --> <item android:drawable="@drawable/btn_location"/> <!-- default --> The problem here is that I'm also trying to change the textColor as

Changing focus from Button in ListView row to list item

雨燕双飞 提交于 2019-12-14 00:26:06
问题 I have a ListView with list items that have a Button on them. You can no longer select the list item, only the Button on the list item. How do you change the focus back to the list item? 回答1: For the Button in your list row layout add the attribute: android:focusable="false" 来源: https://stackoverflow.com/questions/9572990/changing-focus-from-button-in-listview-row-to-list-item

How to flag only one instance of an activity in android?

我的未来我决定 提交于 2019-12-13 07:46:54
问题 In my android application, I have a button that, when clicked opens another activity. The problem is that the user could keep tapping on that button many times quickly and it would open a lot of those new activities. How can I force it so that only one of those activities can be open at a time? I want to avoid doing big things like disabling buttons or putting loading screens. 回答1: If the scenario is as simple as you describe, you can launch the Activity with FLAG_ACTIVITY_SINGLE_TOP. That

How do I create a button programatically?

梦想的初衷 提交于 2019-12-13 07:17:34
问题 I just want to dynamicly add buttons to my Layout when i want to. The buttons should be like this XML Button: <Button android:text="Text" android:gravity="bottom" android:textSize="10dp" android:textColor="#FFFFFF" android:layout_width="wrap_content" android:background="@drawable/attack1" android:layout_height="wrap_content" android:id="@+id/workingButton"> </Button> . public class GravityIssueActivity extends Activity { LinearLayout layout; Button newButton; Button buttonByXml; @Override

Bounds in custom triangle button

半城伤御伤魂 提交于 2019-12-13 07:01:49
问题 I created a custom button as shown in the image. My problem is that the bounds still clickble. Is there any way to wrap the triangle. Image custom button My shape xml file : <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <rotate android:fromDegrees="45" android:toDegrees="45" android:pivotX="-10%" android:pivotY="87%" > <shape android:shape="rectangle" > <stroke android:color="@color/transparent" android:width="30dp"/>