This question already has answers here:
error: package android.support.design.widget does not exist
(4 answers)
Closed 4 years ago.
I've added xml code to have a floating action button on my screen (no functionality right now but will) but when I go onto the design view of xml, instead of showing the email icon image, it shows just text like 'floating action button': '
Could someone explain what I've done wrong?
the code I use:
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#android:drawable/ic_dialog_email"
android:layout_gravity="bottom|end"
app:elevation="6dp"
app:pressedTranslationZ="12dp"/>
It means the correct library is not added. Try adding design library
implementation 'com.android.support:design:27.1.1'
Related
This question already has answers here:
Set FAB icon color
(18 answers)
Closed 4 years ago.
I am using one of the preset button designs (an add button) for my FAB. I was able to change the colour of the background colour of the button but the plus is green and I want to change that. How can I change that?
Using
android:tint
property you can set the color like this
<android.support.design.widget.FloatingActionButton
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:tint="#android:color/white"
android:src="#android:drawable/ic_input_add" />
Hope this helps. Good luck :)
This question already has answers here:
Unable to use drawable in EditText inside TextInputLayout
(5 answers)
Closed 6 years ago.
I am using code bellow to display User name Input. EditText is working properly but Right side display icon is not visible.
<android.support.design.widget.TextInputLayout
android:id="#+id/login_screen_edit_text_username_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:id="#+id/login_screen_edit_text_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/label_username"
android:inputType="text"
android:drawableRight="#mipmap/email_icon"
android:text="abcd#gmail.com"
/>
</android.support.design.widget.TextInputLayout>
I am testing this code on Nexus6p android version 6.0. Parent layout is LinearLayout.Please update if anybody facing same issue and got fix for it.
use
android:drawableEnd="#mipmap/email_icon"
instead of
android:drawableRight="#mipmap/email_icon"
This question already has answers here:
Button background as transparent
(15 answers)
Closed 6 years ago.
How do I add a button on a background image in Android?
I already added the background now I want to add a button and make it work within the background. I have tried to add multiple buttons but then they all don't work, I'm not sure if its the layout or something else.
This is what I have so far:
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="back"
android:id="#+id/button2"
android:layout_alignTop="#+id/button"
android:background="#drawable/scan1"
android:layout_centerHorizontal="true"
android:layout_alignParentStart="false"
android:layout_alignParentLeft="false" />
i edited the code, so the "scan1" drawable is showing red.
Use FancyButtons library to create buttons with transparent background. Set fb_defaultColor param as follows:
fancy:fb_defaultColor="#android:color/transparent"
Using this library, you won't lose ripple effects on button clicks.
You may also use: in your xml:
android:background="#null"
or in code:
button.setBackgroundColor(Color.TRANSPARENT);
Transparent button
android:background="#null"
or
android:background="#android:color/transparent"
android:background="?android:attr/selectableItemBackground"
Add this to your button xml.. Hope it helps
I am trying to learn to work on scrolling activity (android studio) but I am unable to change the default Fab Icon provided by the activity itself. Can someone please provide some guidance about changing the Fab icon to another icon image?
(In short: How to change "mail" Icon to "+" icon)
in your xml change src drawable:
android:src="#android:drawable/ic_dialog_email"
to your desirable icon.
Plus Icon Image add into Drawble folder
Here is image.
Write in your xml
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="#dimen/fab_margin"
android:background="#C2185B"
android:src="#drawable/ic_action_add" />
change your android:src="#android:drawable/your_image.png"
where your_image is your image in drawable folder
It took me a while to find the solution a easyone for this simple problem,in .java(Scrolling activity)you will be able to locate
fab,Right click it -->Go to--> Declaration-->The page you land is the page you need to edit for changing the Fab icon.
Upload the fab icon Image you have in
*android:src="#drawable/*****"*.
and the fab icon will be changed
It should be noted that ic_input_add is found in the R.drawable reference at https://developer.android.com/reference/android/R.drawable.html#ic_input_add
In Android Studio 3.3.2 in a new Kotlin program, this setting is found in the activity_main.xml file. The default FloatingActionButton settings are:
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="#dimen/fab_margin"
app:srcCompat="#android:drawable/ic_dialog_email"/>
The last line of this code block is being changed to:
app:srcCompat="#android:drawable/ic_input_add"/>
You will notice a preview of the drawable image next to the line number if you are editing in Android Studio 3.3.2. Click this image and you can open the resource. Here you will see a full view of the image and the path to the image. In my case it's in the ~\plugins\android\lib\layoutlib\data\res\drawable-ldpi directory. It may be different for you, but easy enough to determine from there. Other compatible drawables are found there as well.
Here is a list of other drawables from the reference (be sure to check the reference as it may change):
ic_btn_speak_now
ic_delete
ic_dialog_alert
ic_dialog_dialer
ic_dialog_email
ic_dialog_info
ic_dialog_map
ic_input_add
ic_input_delete
ic_input_get
ic_lock_idle_alarm
ic_lock_idle_charging
ic_lock_idle_lock
ic_lock_idle_low_battery
ic_lock_lock
ic_lock_power_off
ic_lock_silent_mode
ic_lock_silent_mode_off
ic_media_ff
ic_media_next
ic_media_pause
ic_media_play
ic_media_previous
ic_media_rew
ic_menu_add
ic_menu_agenda
ic_menu_always_landscape_portrait
ic_menu_call
ic_menu_camera
ic_menu_close_clear_cancel
ic_menu_compass
ic_menu_crop
ic_menu_day
ic_menu_delete
ic_menu_directions
ic_menu_edit
ic_menu_gallery
ic_menu_help
ic_menu_info_details
ic_menu_manage
ic_menu_mapmode
ic_menu_month
ic_menu_more
ic_menu_my_calendar
ic_menu_mylocation
ic_menu_myplaces
ic_menu_preferences
ic_menu_recent_history
ic_menu_report_image
ic_menu_revert
ic_menu_rotate
ic_menu_save
ic_menu_search
ic_menu_send
ic_menu_set_as
ic_menu_share
ic_menu_slideshow
ic_menu_sort_alphabetically
ic_menu_sort_by_size
ic_menu_today
ic_menu_upload
ic_menu_upload_you_tube
ic_menu_view
ic_menu_week
ic_menu_zoom
ic_notification_clear_all
ic_notification_overlay
ic_partial_secure
ic_popup_disk_full
ic_popup_reminder
ic_popup_sync
ic_search_category_default
ic_secure
Change the keyword as given below will show you the add button.
app:srcCompat="#android:drawable/ic_input_add"
When following this Android tutorial using AppCompat V7 to get the new Tool Bar work, the android.support.v7.widget.Toolbar supports android:elevation on SDK's < Lollipop. This is because they use android.support.v7.widget.Toolbar and not Toolbar.
Is there equivalent for button? Something like android.support.v7.widget.Button? (This one not exist) Or any other workaround in the kind of overlaying the Button in some view supporting elevation? (I don't want implementation of creating custom shapes with gradients for look & feel of elevation).
Thanks,
You can use the Floating Action Button from support design library .
Use below code to the layout where you want this button.
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#mipmap/ic_fab"
android:layout_gravity="bottom|end"
app:backgroundTint="#0091b4"
app:elevation="6dp"
app:pressedTranslationZ="12dp"
android:layout_margin="10dp"
android:scaleType="centerCrop" />
Do add design dependency in your project
Add below in the dependency list of build.gradle file
compile 'com.android.support:design:23.0.1'
Unfortunately you will have to do what you do not want. Because there is no support button view yet. (As i know :) perhaps some omniscient person will correct my answer)