Button appearing differently in AVD/Graphical layout and on a actual phone - android

I have modified my button to look like a spinner. On the AVD and Graphical layout it appears exactly like a spinner would but on my phone it appears quite different.
Button on the AVD:
Button on my phone:
Can someone tell me why this is happening??
Here is the Button layout in XML:
<Button
android:id="#+id/datebutton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:hint="#string/datebuttontxt"
android:onClick="datepicker"
android:gravity="center"
style="#android:style/Widget.DeviceDefault.Light.Spinner" />
Changing the button background to invisible is not helping.
Also, If I use an actual spinner it would appear correctly, just like it shows on the AVD.

Widget.DeviceDefault.X styles change between different devices, use #android:style/Widget.Holo.X styles to get a consistant look and feel.
In your case:
#android:style/Widget.Holo.Light.Spinner

Related

Android Radio Button Icon is too small/tiny in tablet (7" or 10" inches), but normal in Mobile Device

Here is the XML code for the RadioButton.
<androidx.appcompat.widget.AppCompatRadioButton
android:buttonTint="#android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layoutDirection="rtl"
android:text="#string/largest_discount"
android:textAllCaps="true" />
I haven't added any custom icons/button for this RadioButton. Using the default colour and style of the RadioButton. But the icon looks too tiny/small of the RadioButton in Tablet, it looks normal and decent in Mobile device. Here is the attached image. The left one is the Tablet and the right side is a Mobile device. Clearly seen that Tablet icon is too small.
Do let me know what's wrong here. Any help would be appreciated.

Changing text while pressing button android studio

I've tried a tutorial on youtube but it doesn't work,when I click the button nothing happens.
When I press the button I want to Change the layout activity and also to be set on the new layout one random text from lets say other 10 and on this current layout I wanna have the button which will randomly change the first text to another one.
Here is what codes I've used and didn't worked out.
#I can't add the codes because It doesn't let me post it here..it says something like isn't valid but you see everything in the picture,so I did all that code and when I press on my button It doesn't doing anything,what can be the problem?and If you have any idea or if you know any tutorial to help me achieve what I said I want to do upper I would appreciate really much
#as you can see there is a string option which should give me one text of all of them when I click my button,but it doesn't
sorry for image but it seems like those codes aren't good
<LinearLayout
android:layout_width="332dp"
android:layout_height="184dp"
android:layout_marginStart="36dp"
android:layout_marginLeft="36dp"
android:layout_marginTop="48dp"
android:orientation="vertical"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<Button
android:id="#+id/buttonsports"
android:layout_width="match_parent"
android:layout_height="129dp"
android:background="#drawable/ft"
tools:layout_editor_absoluteX="115dp"
tools:layout_editor_absoluteY="291dp" />
<TextView
android:id="#+id/sports"
android:layout_width="216dp"
android:layout_height="117dp"
android:text="TextView"
tools:layout_editor_absoluteX="95dp"
tools:layout_editor_absoluteY="246dp" />
</LinearLayout>
this is how big my text box is,the "sports" is the id for TextView which is "abc"
In your xml you have a LinearLayout for which you have set the height to:
android:layout_height="184dp"
and inside there is a Button with height:
android:layout_height="129dp"
So for the TextView below there is left maximum 55dp but you set:
android:layout_height="117dp"
This means that at least half the TextView is not visible.
In your code you set a random text to the TextView when you click the Button.
You say that nothing happens.
Is there a case that the text is being set but you can't see it because the TextView is mostly hidden?
Change the heights of the views and you will find out.

Android 5.0 makes unselected checkboxes invisible when background is white

I have an android app that has been working fine pre-Android 5.0. With the update, I noticed that checkboxes and radiobuttons placed on white backgrounds are not visible if they are not selected. For example, this is what a checkbox looks selected and unselected in jellybean:
As you can see, there is a light gray square when the checkbox is not selected. However, after updating to lollipop, this is what it looks like:
So, as you can see, there is no gray square or anything that suggests there is a checkbox here. The same problem happens with radiobuttons. I really don't want to go trough the pain of creating new drawables just for this simple ting. I have seen that checkboxes within the accessibility menu of android 5 have a nice square, but haven't figured out how to make mine look the same:
I tried creating a new android project and just adding some checkboxes and radio buttons with a white background, but they are still invisible when unchecked. I'm using xamarin studio and c#, if that makes any difference. Anyway, I'll understand any java code you post.
This is what my checkbox code looks like:
<CheckBox
android:layout_width="wrap_content"
android:layout_height="0dp"
android:id="#+id/chkSeleccionar"
android:layout_gravity="right"
android:gravity="center_vertical"
android:clickable="false"
android:focusable="false"
android:scaleX="1.5"
android:scaleY="1.3"
android:layout_weight="50"
/>
I couldn't get the theme working, but what did work for me was the following:
android:button="#drawable/abc_btn_check_material"
android:buttonTint="#color/red"
Put this into your CheckBox XML layout.
Just change the
android:buttonTint="YOUR COLOR"
It works.
Make sure you are using a Material theme for Android 5.0 devices - this will ensure you're styling remains consistent with other components. Look for an android:theme element in your AndroidManifest.xml file (either on your application or on an individual activity), then look up what style is set there and check the parent attribute for the style.
Add this attribute
android:buttonTint="#EEEEEE"

how to achieve Google Play Music-like button look in my app?

Hi I have been inspired by a Google Music app and been trying to achieve the same effect on the button when it is pressed. The shot will help u understand:
SO here the button gets that semi-transparent nice-looking effect. Unfortunately, i ve gone nowhere with it, i just managed to similar button but now it doesnt change color when i press it? Im really stuck and need help, im a novice in android dev, i have been trying selectors but when I set a selector to button background the app fails at runtime.
Here is a screenshot of my button:
For this button, to achieve the shadow I used the card_background.9.png file so it also changes the whole button background to white. I assume what is why the button looses the default pressed state.
XML code for the button:
<Button
android:id="#+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Facebook"
android:drawableLeft="#drawable/facebook_icon"
android:background="#drawable/card_background"
android:padding="15dp"
android:textSize="20sp"
android:drawablePadding="10dp"
/>
You can create your custom button with creating a custom style. In this style you can define different images for different button states (for example enabled, pressed...). Take a look at this tutorial.

Removing Android ToggleButton's green indicator light

I would like my app to have a day of week selector with multiple day selection capability. I'm using ToggleButtons for this right now, but because of the indicator lights a ToggleButton takes too much space on the screen. Without the lights, my ToggleButtons would look like normal (toggleable) Buttons and they could fit in one row. How can I hide the lights?
The answer is this part:
android:background="#android:drawable/btn_default"
For example, following will make the light disappear and toggle button would look like a default button, but with the toggle functionality:
<ToggleButton android:id="#+id/your_btn"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textOn="On" android:textOff="Off"
android:background="#android:drawable/btn_default" />
You can use a custom android:background drawable for them, that will override the graphics including the indicator light. If you look at Android: using framework drawables in custom button selector, there's instructions for copying resources from the SDK to your own project. You presumably could copy the platform normal button drawable and use that as your background.

Categories

Resources