How to display background image in text view - android

can anybody tell how to display background image in a TextView in android?

If you are working with xmls you can add it as Praveen Chandrasekaran said doing:
android:background="#drawable/myResouce"
Before that you have to put your image file inside the res/drawable folder.
You can also change it from the code doing:
mTextView.setBackgroundResource(R.drawable.myResouce);

add a android:background="#drawable/imagefile" attribute on your TextView tag. Before that you have to put your image file inside the res/drawable folder.

android:background="#drawable/mark"
Also review.... your background image should be a 9.png and add some paddings for your content
android:layout_marginLeft="10dp" android:layout_marginRight="10dp"
android:layout_height="400dp" android:background="#drawable/mark"
android:paddingTop="5dp" android:paddingBottom="5dp" android:paddingLeft=

Related

ImageView doesn't appear

I have dragged an ImageView to layout and I selected the picture. But when I execute the application, It doesn't appear. What can I do to solve this ?
ImageView XML code;
<ImageView
android:layout_width="250dp"
android:layout_height="250dp"
app:srcCompat="#mipmap/idlepoor_moneys"
android:id="#+id/imageView4"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
Add this property in Your image View
android:src="#mipmap/idlepoor_moneys"
Remove the following line from your code
app:srcCompat="#mipmap/idlepoor_moneys"
As allready said change
app:srcCompat="#mipmap/idlepoor_moneys"
to
android:src="#mipmap/idlepoor_moneys"
Also I recommend to put your images in the #drawable folder. The mipmap is where app icons are stored when making an app.
app:src="#drawable/idlepoor_moneys"
You can easily find the drawable from your project map. If you can't find it you can always right click the folder to get the path to it.

ImageButton Border Transparancy - Removing the square border around round image is not working?

Hello Guys I need some help in creating Imagebutton. I created custom button on PS and then saved it in PNG format with transparent background. After that i patched my image with 9patch. Now i am using that image as a button in my layout but the image is showing colored background corners. I tried alot of things but its not removing.
Here is my XML
<ImageButton
android:id="#+id/mybutton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
android:src="#drawable/registerbutton"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginBottom="123dp" />
Keep the background attribute as #null like this :
android:background="#null"
If still you are getting that corner, it might be from the png file that you are using.
This is an example of what i get from #null
Probably the ouput of "9patching" operation added corners. Open the file and check if there are corners or not.
If that won' help, try switching android:src attribute with android:background attribute.
And u can make .png button online using this site

Image loading in android studio

I am not able to load the image. I tried the following
put the image in the drawable folder
then use the Image View tag
then able to load the picture for the app's icon, but not able to if I try to use picture inside my application.
what should I do to use a picture inside the created application
If you want to use an image from drawables you shold reference it from your layout via ImageView control:
<ImageView
android:id="#+id/this-is-your-image-view-id"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1.00"
android:src="#drawable/this-is-your-drawable-name" />
I faced the same problem,fixed by using .png image,not other format .

how to resize a drawable image inside an EditText

I have an edit text with a background image,
I want to add a drawable in the center of the edit text.
<EditText
android:id="#+id/etReceipt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:clickable="true"
android:drawableStart="#drawable/Draw _Image"
android:background="#drawable/bgImage"/>
is ther a possibility to resize the drawable to fit with the edit text?
is it possible to put it in the center?
Create center.xml in res/drawable folder and add this code
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="#drawable/bgImage"
android:gravity="center"/>
In your edit text add:
android:background="#drawable/center"
Hope this helps, happy coding!

How do I include an image in an Android interface?

I am creating my first Android interface and I want to include a logo on. The logo is called logo.jpg. How do I do this?
Put logo.jpg into the res/drawable directory. Or if you have different size logos, put them in res/drawable-mdpi, res/drawable-hdpi, etc. See Providing Resources for detailed information.
To display the image, use ImageView. The XML refers to the image like this:
android:src="#drawable/logo"
you can add your logo( name logo.png for example) to the folder drawable , and then , add an imageView on your layout xml like this :
<ImageView
android:id="#+id/logo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="#drawable/logo" <!-- this is the drawable source of your imageView -->
/>
Then place an image view where you would like the logo to be and set the image resource to R.drawable.logo or what ever the resource name is.

Categories

Resources