Want ToggleBotton to NOT show ON/OFF text - android

Im trying to make my ToggleBotton to NOT show the ON/OFF cause I'm using a backround of Green/Red that show if it's on or off and the text just messes things up..
Thank you.
<ToggleButton
android:id="#+id/toggle"
style="#style/AppBaseTheme"
android:layout_width="60dp"
android:layout_height="60dp"
android:background="#drawable/toggle_selector"
android:layout_below="#+id/rel1"
android:checked="true" />

What about just setting the text for On and Off to be an empty string like
android:textOff=""
android:textOn=""

Related

Change the style of a Checkbox to Button style

I would like to change the style of the Checkbox.
Is it possible to let the checkbox look the same like the button?
Thought about adding an image to the checkbox, but don't know how to safe the button image in good quality out of Android Studio. Maybe it's possible without adding an image?
<Button
android:id="#+id/b0"
android:layout_width="70dp"
android:layout_height="wrap_content"
android:insetLeft="3dp"
android:insetRight="3dp"
android:text="#string/_0"
android:textAppearance="#style/TextAppearance.AppCompat.Large"
app:layout_constraintBottom_toTopOf="#+id/b17"
app:layout_constraintEnd_toStartOf="#+id/bUnDo"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="#+id/cDouble"
app:layout_constraintTop_toTopOf="parent" />
<CheckBox
android:id="#+id/cDouble"
android:layout_width="70dp"
android:layout_height="wrap_content"
android:text="#string/drouble"
app:layout_constraintBottom_toTopOf="#+id/b18"
app:layout_constraintEnd_toStartOf="#+id/b0"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="#+id/cTriple"
app:layout_constraintTop_toTopOf="parent" />
Appreciate every hint.
Thanks and regards.

Make android button look like a spinner

I have a buttons and I want to make them look like a spinner.
I've found this post from 2011:
Android: Drawing a button as a spinner
And none of the solutions worked for me.
It's better if I could use my customed background.
Those are the buttons:
<Button
android:id="#+id/new_msn_act_type"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:background="#drawable/button_border"
android:onClick="showPopup"
android:padding="6dp"
android:text="Order Type"
android:textColor="#color/colorPrimary" />
<Button
android:id="#+id/new_msn_datetimepick"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:background="#drawable/button_border"
android:onClick="pickDateTime"
android:padding="6dp"
android:text="Date and Time"
android:textColor="#color/colorPrimary" />
I tried each one of the solutions suggested in the post, including
style="?android:attr/spinnerStyle"
And they didn't work. How can I solve it ? Thanks
I need it to be a Button, because I want to use drawable style as background, and I want it to open PopupMenu and I worked hard for the popup to present icons correctly...
I solved it with:
android:drawableRight="#drawable/arrow_down_float"
You can also choose custom drawables

How can I get the text in a button exactly in the centre?

I am unable to get the '×' (multiplication symbol) in the shown button exactly in the centre. It seems a bit off. How can I bring it back in centre?
Here is the xml code for it.
<Button
android:id="#+id/button_multiply"
android:layout_marginLeft="24dp"
android:layout_marginRight="16dp"
android:alpha="0.5"
android:background="#drawable/rounded_corner"
android:elevation="24dp"
android:onClick="onClick"
android:text="#string/button_multiply"
android:textColor="#android:color/white"
android:textSize="30sp"
android:gravity="center"
android:layout_width="60dp"
android:layout_height="60dp" />
Thanks for help
It's an odd problem that catches everyone at first - you need text alignment AND gravity which must match
<Button
android:textAlignment="center"
android:gravity="center"
... />

Show to set text visible in OFF state at SwitchCompat?

Currently my SwitchCompat looks like the image below (the top portion), however I need to have visible text in OFF state.
How would I achieve this?
Are you using background images? if it does you need set text on images not on switch.
<android.support.v7.widget.SwitchCompat
android:id="#+id/autoLocation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="#color/colorPrimary"
android:checked="false"
android:paddingBottom="10dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:paddingTop="10dp"
android:text="#string/autoLocation"
android:textColor="#ffffff"
android:textOff="Off"
android:textOn="On"
android:textSize="20sp"
app:showText="true" />

Buttons in dialog boxes sticking to the bottom

I'm building a custom dialog box for my Application. While doing so, my OK and Cancel buttons are going right to the bottom of this view i.e. to the bottom edges of the dialog box. How can I pull these up a little so that there is a slight gap between the buttons and the bottom edge of the dialog box.
My XML code is as follows:
<TextView
android:id="#+id/settingsview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="18dp"
android:text="Select Settings" />
<RadioButton
android:id="#+id/onemin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/settingsview"
android:layout_below="#+id/settingsview"
android:layout_marginTop="14dp"
android:text="#string/radio_one" />
<RadioButton
android:id="#+id/twomin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/onemin"
android:layout_below="#+id/onemin"
android:text="#string/radio_two" />
<RadioButton
android:id="#+id/tenmins"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/twomin"
android:layout_below="#+id/twomin"
android:text="#string/radio_three" />
<Button
android:id="#+id/set"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/onemin"
android:layout_below="#+id/tenmins"
android:layout_marginRight="54dp"
android:layout_marginTop="30dp"
android:background="#drawable/custom_btn_livid_brown"
android:text="#string/submit_btn" />
<Button
android:id="#+id/cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/set"
android:layout_alignBottom="#+id/set"
android:layout_toRightOf="#+id/twomin"
android:background="#drawable/custom_btn_livid_brown"
android:text="#string/cancel" />
have you tried using gravities? this is my solution when i have trouble with positioning my widgets.
basically, you need some parent "container" where your buttons are in and then position them with changing the gravities within the container for your widgets.
Vogella has a good tutorial for this topic!!
vogella-tutorial
Though you don't provide your full code here.Not sure whether you use above things in a LinearLayout or RelativeLayout.But as you say..
How can I pull these up a little so that there is a slight gap between
the buttons and the bottom edge of the dialog box
So i think android:layout_marginTop="" can do the trick,if you decrease those values.
Use
android:layout_marginTop="10dp" //change this value according to you need
And if you want to move you buttons a little bit left rather than right then change..
android:layout_marginRight="30dp" //change this value according to you need
I show here 2 examples of how can you improve those condition.If you still face problem then post full xml code here so that i can test that in my environment.

Categories

Resources