I'm using Eclipse and I just created a home page (menu) with 2 image buttons, but I am getting this error:
The graphics preview in the layout editor may not be accurate:
Paint.setShadowLayer is not supported.
What does it mean? And how can I solve it?
I am using API 21.
It means the preview doesn't know how to implement setShadowLayer. This means the preview won't look exactly like the result rendered on the device. Which is one of many reasons why you shouldn't trust the preview app- always test your layouts on a physical device before assuming they're done.
In my case it was a new component, a EditText with support of showing/hiding a password. It appeared in support library v.24.2.0. I mean:
<android.support.design.widget.TextInputLayout
android:id="#+id/password_input_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
app:passwordToggleEnabled="true">
<android.support.design.widget.TextInputEditText
android:id="#+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
android:hint="#string/password"
android:inputType="textPassword"
tools:text="aaaaaaaaaaaaaaaaaaa"/>
</android.support.design.widget.TextInputLayout>
Of course, on a real device it is shown right (and in preview also).
As the first answer is true, but for fixing this issue you can try this (If you are using android studio) :
File > Invalidate Caches / Restart... > Invalidate and Restart
Related
My android sudio design editor don't render material TextInputLayouts. I already tried invalidate caches. Every other element is rendering correct also other material elements
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/ti"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="20dp"
android:layout_marginEnd="30dp"
android:layout_marginBottom="20dp"
android:hint="#string/street_number">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="50dp"
android:inputType="text"
android:text="#{vm.user.streetnumber}" />
</com.google.android.material.textfield.TextInputLayout>
You have to change in build.gradle
implementation 'com.google.android.material:material:1.2.0-alpha02'
It seems newer versions are not rendered correctly.
See:how to solve render problem Path.op() not supported?
You need to change the theme in the layout builder to match the one of your app.
in my case Update Android Studio, problem fix
Show all warnings in XML and press to recommendation that wrapped with blue and press modern rendering feature and Restart Android Studio. You can switch off this feature.
So I have been working on an Android application to make an application for use with DJI's consumer level drones. I have been making the user interface and using XML throughout the project with no issues. I want to add a .png to the UI just so that my logo is showing. When I preview it in Android Studio, I can see the logo being shown but when it is run on the tablet, it is not there. Everything else using XML is fine though. I even preview using the same resolution/ screen size as my tablet I am using (cheap Hudl 2 tablet).
If anybody has any ideas about how I can get this to work, I would appreciate it. I have shown my university lecturer it and he couldn't give me an answer too as nothing seems to be out of the ordinary.
Android studio preview
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="#drawable/macrosfordji"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true" />
Try this (android:src="..." instead app:srcCompat="..."):
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/macrosfordji"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true" />
I seem to have quite a specific problem. I have two tablets, one runs on Android 6.0.1, the other on 5.1.1.
I have an activity and a fragment (the fragment is located on an activity). Each has an EditText element with the following layout:
<EditText
android:id="#+id/etInputForm_1_1"
android:layout_width="250dp"
android:layout_height="30dp"
android:layout_below="#id/tvDescription_1"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:cursorVisible="true"
android:imeOptions="actionNext"
android:paddingBottom="5dp"
android:paddingLeft="5dp"
android:paddingStart="5dp"
android:textColor="#color/Black"
android:textSize="15sp"/>
The problem is, if I test it on the device with Android 6.0.1, everything seems to be ok, I can input text wherever I want to, however on the device with 5.1.1, the EditText in the fragment always seems to be empty no matter how many letters I type (the EditText in the activity still works fine).
But the logs still show that the text IS there (however we can't see it).
Anyone had similar problem and a solution to this?
I had a similar issue where the edit text hint wouldn't go away (representing text was in the field) and no text would show up when I was typing but my logs showed text was indeed in the field. I also had an issue where my spinners would not show the selected option
I solved it by enabling hardware acceleration for my application. Since it is enabled by default (I believe) I removed this line from my <application></application> section of my manifest file: android:hardwareAccelerated="false"
My issue resolved after removing following line from edit text.
android:textAllCaps="true"
The problem was resolved by using android.app.Fragment instead of android.support.v4.app.Fragment. Seems that the support fragment class is buggy when using on tablets with Android 5.1.1.
I'm using Eclipse and I just created a home page (menu) with 2 image buttons, but I am getting this error:
The graphics preview in the layout editor may not be accurate:
Paint.setShadowLayer is not supported.
What does it mean? And how can I solve it?
I am using API 21.
It means the preview doesn't know how to implement setShadowLayer. This means the preview won't look exactly like the result rendered on the device. Which is one of many reasons why you shouldn't trust the preview app- always test your layouts on a physical device before assuming they're done.
In my case it was a new component, a EditText with support of showing/hiding a password. It appeared in support library v.24.2.0. I mean:
<android.support.design.widget.TextInputLayout
android:id="#+id/password_input_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
app:passwordToggleEnabled="true">
<android.support.design.widget.TextInputEditText
android:id="#+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
android:hint="#string/password"
android:inputType="textPassword"
tools:text="aaaaaaaaaaaaaaaaaaa"/>
</android.support.design.widget.TextInputLayout>
Of course, on a real device it is shown right (and in preview also).
As the first answer is true, but for fixing this issue you can try this (If you are using android studio) :
File > Invalidate Caches / Restart... > Invalidate and Restart
I have a fairly simple xml file that has an image button in it. The image shows up fine on the Graphical Layout xml designer, shows up fine when I run a development build, but as soon as I create the signed apk file and run it, the image no longer shows up. It's just an empty button. I can't think of a reason why, any ideas? The xml file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/navigation_root"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/navigation_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="TextView"
android:textAppearance="?android:attr/textAppearanceLarge" />
<SeekBar
android:id="#+id/navigation_seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:padding="5dp" />
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp" >
<ImageButton
android:id="#+id/part_select_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/chapter_select" />
<Button
android:id="#+id/navigation_ok_button"
android:layout_width="75dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="#string/ok" />
<Button
android:id="#+id/navigation_cancel_button"
android:layout_width="75dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="#string/cancel" />
</LinearLayout>
</LinearLayout>
The image #drawable/chapter_select is a fairly small (41*41) png file that is in the res/drawable folder.
Seems like this is a bug with android, where sometimes the first image in the drawable folder doesn't show up. Added a dummy image called aaaa.png to the drawable folder and problem was solved. Found the answer here: ImageButton does not display a particular drawable
One of the reason is:
If you are using Vector file as a drawableLeft or drawableRight (or drawableStart or drawableEnd) in layout.xml, then you have to use androidx.appcompat.widget.AppCompatButton (formerly android.support.v7.widget.AppCompatButton) instead of Button.
Simple View like Button or Textview doesn't support Vector file as a drawableLeft or drawableRight (or drawableStart or drawableEnd) in my case.
Had the same issue and resolved it by removing all special characters. In my case it was dashes '-' in the filename:
background-720.png => background.png.
try to put the image in drawable-hdpi and drawable-mdpi folder
depends on what device you run you app , the image is searched in these folders...
But puting in drawable means that the image should be available everywhere, but somethimes (depends on your manifest settings) this could not be true, I mean you can turn of the compatibility mode.
also you can try dinamically at run time to set the image to the view
iv.setImageResource(R.drawable.somethig);
My situation was weird.Everything was correct until integrating FireBase Crash report to my Application.
I just added compile 'com.google.firebase:firebase-crash:11.0.1' & DrawableLeft vanished .When i went through the xml , noticed a warning (In lined below).
So added android:drawableStart & issue gone.
Still I am wondering about the relation of FireBase Crash reporting to the same.
Using left/right instead of start/end attributes Using Gravity#LEFT
and Gravity#RIGHT can lead to problems when a layout is rendered in
locales where text flows from right to left. Use Gravity#START and
Gravity#END instead.
Similarly, in XML gravity and layout_gravity attributes, use start
rather than left. For XML attributes such as paddingLeft and
layout_marginLeft, use paddingStart and layout_marginStart.
NOTE: If your minSdkVersion is less than 17, you should add both the
older left/right attributes as well as the new start/right attributes.
On older platforms, where RTL is not supported and the start/right
attributes are unknown and therefore ignored, you need the older
left/right attributes.
There is a separate lint check which catches that type of error.
(Note: For Gravity#LEFT and Gravity#START, you can use these constants
even when targeting older platforms, because the start bitmask is a
superset of the left bitmask. Therefore, you can use gravity="start"
rather than gravity="left|start".)
Check your image size. If you're using an unnecessarily large asset when actually deployed it might just not show despite looking correct in the designer.
Well ! in my case setting MinifyEnabled false and shrinkResources false is working fine now.
i was getting image from drawable. it was working pretty nice in debug version but after release version of apk it was showing sometime blank ImageView.
minifyEnabled false
shrinkResources true
**
See the Screenshots
**
Hope this may help anyone.
I had a similar problem where a drawable png was not showing up in Android Studio. Deleted the file and added it again in the drawable folder and it Worked for me.