Getting this error since I started changing device for testing. Did some searching and none of it help because they are outdated. Any help is appreciated!
xml file
<ImageView
android:id="#+id/loginpanel"
android:layout_width="491px"
android:layout_height="210dp"
android:layout_marginStart="41dp"
android:layout_marginTop="146dp"
android:layout_weight="1"
android:background="#drawable/loginpanel"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="#+id/numpanel2"
android:layout_width="388px"
android:layout_height="452px"
android:layout_marginStart="80dp"
android:layout_marginTop="368dp"
android:layout_weight="1"
android:background="#drawable/numpanel1"
android:alpha="0.95"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
These are my folders, there's no drawable-v24 folder
Make sure your loginpanel and numpanel1 images is inside drawable folder not inside drawable-v24 folder
move your both images loginpanel and numpanel1 inside drawable
just copy-paste from drawable-v24 to drawable folder it will work
Related
I'm getting a build error: 'failed linking file resources' in Android Studio. How do I solve this?
This is the problem:
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center_horizontal|center_vertical"
android:layout_marginBottom="75dp"
android:gravity="center"
android:textSize="400sp"
android:removeView=""
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent" />
android:removeView doesn't exist. Remove that line.
there is some thing wrong in one of the XML files
you can go back and check your recently added/changed XML
for me it was spelling mistake(vible instead of visible)
<ProgressBar
android:id="#+id/prog_bar"
style="#style/ProgressBar.Green"
android:layout_width="0dp"
android:layout_height="20dp"
android:layout_weight="1"
**android:visibility="vible"**/>
Please help me with strange issue. I have simple linear layout with three imageviews, with same sizes. It look normal in Android Studio design, but on the device third imageview has different size. How to fix it? p.s. image resources have same sizes
part of layout:
<LinearLayout android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal"
android:gravity="center"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp">
<ImageView android:id="#+id/twitterlb"
android:layout_height="match_parent"
android:layout_width="60dp"
android:src="#drawable/tw_circle" android:scaleType="fitCenter"/>
<ImageView android:id="#+id/facebooklb"
android:layout_height="match_parent"
android:layout_width="60dp"
android:src="#drawable/fb_circle" android:scaleType="fitCenter"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"/>
<ImageView android:id="#+id/linkedinlb"
android:layout_height="match_parent"
android:layout_width="60dp"
android:src="#drawable/in_circle" android:scaleType="fitCenter"/>
</LinearLayout>
in Android studio:
on device:
<ImageView android:id="#+id/linkedinlb"
android:layout_height="match_parent"
android:layout_width="60dp"
android:background="#drawable/in_circle"
android:scaleType="fitXY"/>
You may try to change scaleType's to fitXY.
Thanks guys, I finally solved the problem. The problem was: same similar res for drawable-mdpi, drawable-xxhdpi, drawable-nodpi, drawable-xxxhdpi,
drawable-hdpi, drawable-ldpi, but different for drawable-xhdpi (5 pixels transparent frame)
I am not able to add image. I downloaded the image and added it to res directory under drawable-mdpi. Then when I try to add the image on the view using imageView, it gives me this error
Couldn't resolve resource #drawable/ball01
Failed to convert #drawable/ball01 into a drawable
Here is my xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
tools:ignore="MergeRootFrame" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView"
android:layout_gravity="center"
android:textSize="32sp"
android:layout_above="#+id/button"
android:layout_centerHorizontal="true" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Enlighten Me"
android:id="#+id/button"
android:layout_centerVertical="true"
android:layout_alignParentRight="true" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView"
android:layout_above="#+id/textView"
android:layout_centerHorizontal="true"
android:src="#drawable/ball01" />
</RelativeLayout>
What am I doing wrong here.
The directory name should be 'drawable-mdpi'. Using a hyphen instead of an underscore.
image name must Digital or lowercase 。 ide only identification.
I had this same problem, I had this image which I named Barcode and then saved it into my drawable folder, then I decided it would be better to have it named barcode with a small b, so I renamed it.
Then I checked if it would work, and I got the same errors as you, after changing the name in my xml to 'Barcode' with a big B, it worked.
solution for me: delete barcode image from drawable and add it again with the name I'm going to use for it, don't change the name while it is in drawable folder.
I had this problem on android studio.
if you close and open project and it continues, all you need to do is RIGHT CLICK on the particular image you put in your "res" folder (that's giving the problem) and refactor-RENAME. Remove spaces in the name of the file. that should do it.
I need to put my own image on some imageView. So that's why I created folder named "drawable" in res folder , and copy my Image in this folder , but now I don't know how to set this image to my imageView in XML code. Can anybody help? and sorry for English :)
In your layout XML file:
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/your_image_name"/>
Replace your_image_name with the name of the image file without the extension (e.g. if your drawable file is called img1.png, the src attribute should have a value of #drawable/img1).
Set it using android:src=""
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/image_name" />
Try this.
<ImageView
android:id="#+id/YourImageViewID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/Your_Image_Name"
/>
This may help you.
//set background as your image by calling the android:background attributes in your xml
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/myimage"
/>
Note: you no need to create any drawable folder by default android project will contain
drawable-mdpi
drawable-hdpi
drawable-ldpi
you can put your image in that.
<ImageView
android:layout_width="150dp"
android:layout_gravity="bottom"
android:layout_height="150dp"
android:id="#+id/image1"
android:layout_marginTop="11dp"
android:background="#drawable/image1"
/>
I've got a .png file in my Drawable folder. How do I make it into an Imageview?
imageView.setImageResource(R.drawable.your_drawable);
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/my_image"
/>