Need to remove the spinner background color but want to display the rectangle drop down mark...can any one please help me..
I used a 9-patch picture to change spinner background. How about this?
<Spinner
android:id="#+id/spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/spinner_bg"/>
spinner_bg:
Related
I created a button and I used android:background="#drawable/background" to change the image however it only displays the default design of a button (purple). How do I set it to the image I have saved in my drawable folder?
I know there is Image Button but I wanted to write a text on the button, but there is no feature where I can write a text on top if I used Image Button
As you have mentioned, you can't put a text if you have used ImageButton.
As far as I understood, you want to have view which has a text on above of image and image on bottom of the text.
If you use android:background feature on Button, button's background will be your drawable image and it won't be as you have expected.
If you are going to use Button for sure, you can use android:drawableBottom feature to show your drawable image on below of your text. And you can basically add button text by using android:text feature.
My advice to you, you should use TextView instead of Button for that case. Because if you do it with the Button as I have mentioned above, your button will have background and you can make transparent background for your button by using below code.
<Button
android:id="#+id/buttonMoreTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
android:drawableBottom="#drawable/ic_baseline_home_24"
android:text="#string/app_name"
android:textColor="#color/black" />
This code will make your Button has a transparent background.
android:background="#android:color/transparent"
But this is a little bit hacky solution. If it won't have background and if you do not have to use Button in your case for sure, you can use TextView for that and basically to show text and drawable on bottom, you can code your TextView basically as below.
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/app_name"
app:drawableBottomCompat="#drawable/ic_baseline_home_24" />
Note: These are very simple xml examples to solve your main problem about showing image on bottom of your text, in same view. If you need anything more, let me know and I would be glad to help.
I want to adjust my spinner like Google android translate
I want to adjust my left spinner text like the right image, below the given code is my left side spinner
<Spinner
android:id="#+id/idFromSpinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="end"
android:layout_marginStart="-3dp"
android:paddingEnd="30dp"
android:paddingStart="15dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
Please help me in this project actually my task is to make a spinner like Google translate
I want to make left spinner left side and right spinner right side margin fix it should not change on increasing or decreasing text length
You can add in android:layout_marginRight="10dp". Just adjust " 10dp" time and time again, good luck on that spinner!
Edit:
The solution is a good use if the left-side spinner is android:layout_toLeftOf="#+id/middle_switcher but if not. You could just use any other Layouts like the GridLayout...
I'm building a simple calculator app and i cannot get ride of extra grey lines next to an ImageButton
Button Code
<Button
android:id="#+id/button_clear"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#color/white"
android:text="AC"
android:textColor="#color/indigo"
android:textSize="18sp" />
ImageButton Code
<ImageButton
android:id="#+id/button_back"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="#drawable/backspace"
android:background="#color/white"/>
As you can see, the buttons are perfect but the ImageButton have grey lines next to them.
I tried settings the Parent background to 'White' and setting the ImageButton background to '#null' too
I tried an Imageview and the Problem still exists
i tried setting the image as background to the button and it still exists
i even tried setting negative margin towards left and right and the problem still exists
Can someone help me out please?
Add this in your ImageButtons
style="?android:attr/borderlessButtonStyle"
I have a suggestion: Use a button to display the ⌫ symbol. For information on how to get the desired results visit: How to make ⌫ symbol backward-compatible in Android Studio?
I'm making an app that is related to a card game and as such has many images of cards appear throughout the app. In one section I need the user to select one of four cards, with only one selection ever being possible and I want to have the card to change color slightly after being clicked to show that it is the currently selected one.
For the bulk of this task a RadioGroup with RadioButtons makes perfect sense since the functionality for having a checked/unchecked state and unselecting all other options when a new one is picked is built in; however, the issue is that I want the buttons to be the cards themselves and therefore an image with no text whatsoever.
At first this post looked promising: Adding custom radio buttons in android
My use of this strategy:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_weight="5"
android:orientation="horizontal">
<TextView
android:id="#+id/label_seatGod"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="8"
android:gravity="center_vertical"
android:text="#string/ex2"
android:textColor="#color/font_condition_labels"
android:textSize="#dimen/font_gen_label_size"
android:textStyle="bold" />
<RadioGroup
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="8" >
<RadioButton
android:id="#+id/radioButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:button="#drawable/power_aphrodite"
android:checked="false"
android:text="#null" />
</RadioGroup>
</LinearLayout>
which resulted in:
This is almost perfect. No text and the entire region of the clickable button space is composed of the image I want, EXCEPT that as you can see the image is not scaled at all and is cropped on the edges. Above the RadioButton you can see a LinearLayout with 4 ImageButtons that demonstrate exactly how I want the RadioButton/card image to appear (ignore the grey for now I haven't finished padding the views).
Essentially, I want a RadioButton that functions normally but looks exactly like one of the four ImageButtons in the top section. Ideally scaleType="fitCenter" would be the fix since it is what I am using in the example ImageButtons, but you cannot apply that attribute to the button drawable of a RadioButton or its background directly.
So how can I get the image to scale and not be cropped without resorting to some performance tanking layout jurry rigging or creating an entirely new RadioButton class?
Thanks in advance.
Maybe you could try adding this to your RadioButton in the xml:
android:scaleType="centerCrop"
I have a button in the list of items rendered with recycler view with a drawable icon. Here is my code.
<Button
android:id="#+id/button_like"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/ic_thumb_up_black_24dp"
android:text="#string/label_like"
android:textSize="11dp"
style="?android:attr/borderlessButtonStyle"/>
Now I want to change the color of the icon ic_thumb_up_black_24dp which is anydpi xml icon from Android material design icons.
I tried android:drawableTint="#android:color/secondary_text_dark" but it does not work.
android:textColor="#android:color/secondary_text_dark" works only on the text color but not on the icon. Can someone help me with this?