I have a listview in which i have an image and text content getting populated from the java code.
I'm unable to get the default orange selector working on the image. The image is placed ontop of button as setBackgroundResource() from Java.
Can anyone help me with the same?
you could do change background by using drawable property of button in xml file. if you will use this setbackgroundresource() then it will ruin the effect of clicking on it. if u still want to use image as background source then u should create selector xml file for the button background.
Related
Hi I wanna set set background gradient for button with kotlin in programming not use XML
how I can create it ?
like this
image
If you don't want to use XML, then you'll have to at least include an image asset that contains such background into the drawable folder of your application.
Once you do that, it should be as simple as calling
yourImageView.setBackgroundResource(R.drawable.you_background_image_asset)
How to create a button as shown in the picture:
and also Image name Button should permanently change color on click. Moreover I will be creating this button dynamically from the android file. So it will be good if somebody suggest me in that way instead of xml files way.
Have a look at the ImageButton class. You can easily create this at runtime so long as you have the picture file for your button in your resources. For it to permanently change colour simply create the different coloured version of the file, put that in your resources folder too and run some code on the onClick of the button to change the image of the ImageButton to the different coloured image. Should take no more than a few lines of code.
See: https://developer.android.com/reference/android/widget/ImageButton.html
I know how to set a button borderless in xml.But how to set button borderless in source code, because it is created dynamically.
Make button image and do:
button.setBackgroundResource(R.drawable.button_image);
button.setBackgroundResource(android.R.color.transparent);
don't forget to put exactly:
android.R.color.transparent
if you put R.color.transparent only (without android), there will be an error in the code when doing this
For some reason im unable to change the background color of an empty webView in xml using android:background. Although I could change it in java code using something like this:
myWebView.setBackgroundColor(Color.parseColor("#D4CAB4"));
But I prefer to do it in xml and I cant find the reason why android:background is not working?
If one can set WebView background color in xml layout the answer is "NO" and the reason behind is:
Set Background Color of WebView. (XML LAYOUT)
You load data on webView in activity class.
The background you set in the step 1 will be ignored and default color will be set.
The only method left is to set the background of WebView after the data is loaded.
I hope this can help you to understand the case here.
I have simple job to do. I have to create an Help page for my android application. On that page I want to just put a full page of text of green color with some background image. Can anybody suggest me how can I do this in my XML file. Either in GraphicalLayoutMode or XML mode.
Please suggest what are the components required to this type of Help page...
android:background="#0abcde"
to set a color
android:background="#drawable/filename"
to set a image background.
use these tags for your layout parent view.