Unable to create a ToggleButton in Eclipse IDE for android - android

In my android XML Graphical Layout, it can not display my ToggleButton. I get some errors (see below). I have checked all other components in the Palette window and the only component that fails to load is ToggleButton. The problem is not project specific. It persists in every project I create.
Note: I have tried dragging it directly as well as using XML code to generate it. But it fails either way and the error is same.
Error :
Exception raised during rendering: -1
Exception details are logged in Window > Show View > Error Log
The graphics preview in the layout editor may not be accurate:
Different corner sizes are not supported in Path.addRoundRect. (Ignore for this session)
Path.isConvex is not supported. (Ignore for this session)
I have referred this question and tried to edit it but the edit was rejected. So please do not redirect me there.
I am using API 21. All the build tools are installed.

I had the same problem and solved by changing my target device screen to any of the xhdpi OR xxhdpi devices.
I'm sorry but I'm not able to post images yet, all you have to do is go to the dropdown menu just above the graphical layout -> General OR Google -> Select the xhdpi/xxhdpi target device you prefer.
I'm also new to android so I'm not able to explain why this is happening, I can only guess it's a compatibility issue or something. I'll try finding out more..
In the meantime I hope this will turn useful for you as well :-)

Problem is in your background drawable. Corners of your rectangle can be rounded all only by a same amount. Just like your error message says. You must set them all to same amount.

Perhaps it is the display theme so ensure that the theme you select matches the android:theme in your activity tag in AndroidManifest.xml. In Android Studio (sorry not eclipse as per question) in the top bar of the preview panel, I had to click the current theme name (which was Light) which brings up the Select Theme panel and then choose my theme under Project Themes (as I had a custom theme - you location may vary).

Related

Failed to load AppCompat ActionBar with unknown error.Android Studio 3.1.3

This was my first time using Android studio and I dont know what are those errors mean or what they implyenter image description here
[Render Problem
Failed to load AppCompat ActionBar with unknown error.
Missing Constraints in ConstraintLayout
This view is not constrained. It only has designtime positions, so it will jump to (0,0) at runtime unless you add the constraints The layout editor allows you to place widgets anywhere on the canvas, and it records the current position with designtime attributes (such as layout_editor_absoluteX). These attributes are not applied at runtime, so if you push your layout on a device, the widgets may appear in a different location than shown in the editor. To fix this, make sure a widget has both horizontal and vertical constraints by dragging from the edge connections.]
Open, res --> values --> styles.xml, here you will find a line like this:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
Change DarkActionBar to NoActionBar
Please change com.android.support:appcompat-v7:28.0.0-alpha3 to com.android.support:appcompat-v7:28.0.0-alpha1 in build.gradle(Module: App).
And click File -> Invalidate Caches / Restart
Of course you need internet access.
It seems there is a bug in com.android.support:appcompat-v7:28.0.0-alpha3
Missing Constraints in Constraint Layout :-
It means some constraints values are not given like distance from the top ,bottom left and right .Here's a link to solve this problem.
And another link if you want to know more about constraint layout
If you are first time using Android studio then you should start with some simple layouts like linear or relative layout.
Hardcoded text :-
Ths is not an error but a warning. As a general rule, you should never use hardcoded strings in your layout but always use string resources (which means the all strings are stored in one separate file where they are easily changeable for different languages and so on).
To convert a hard coded String to a string ressource:
1:put the curser on the hard coded string
2:press ALT + Enter
3:enter a name for your resource
4:click OK
Use stable version always
Always use stable version of libraries. If you are developing an app, you don't want to face these type of errors.
At the time of answering the current most stable version is 27.1.1 and second 28.0.0-rc02.
I suggest use 27.1.1 until 28 stable version release.
implementation 'com.android.support:appcompat-v7:27.1.1'
Sync again
No need of Invalidate/ Restart, Just restart would be okay. Or closing project and reopening from recent would be faster then restart.
Track the support library release.

Android Studio 2.1.2 Rendering problems. VectorDrawable_Delegate.nDraw

When attempting to view a preview of your app you may encounter the following...
Rendering Problems Exception
raised during rendering:
android.graphics.drawable.VectorDrawable_Delegate.nDraw(JJJLandroid/graphics/Rect;ZZ)I
Issue is resolved by de-selecting the API 23 preview as shown below, select the non Preview option.
I think I am a bit late to answer, but the solutions provided above did not work for me.
The rendering error sure does go away, but the rendering displayed finally after selecting API 23 is incomplete or wrong.
In my case, the action bar custom theme color and everything vanished.
So, for everyone out there who has a custom theme in their app, here's a solution -
Check if in the XML preview pane, the rendering theme is selected as the one which is associated with your app in the manifest file.
Select your custom theme in the preview pane, the error will be gone and you will also be able to preview with the latest API (API 24)

Some style/theme attributes are not available in Android Studio

I recently started to learn Android development. But when I click themes, to change it, it says:
Rendering problems. Missing styles....
Then I can't push any Layout or view into the app.
I tried clicking Auto add all the missing attributes, but it doesn't do anything.
One of them works though - only the Manifest Theme.
These screenshot might help:
Screenshot 1
Screenshot 2
See in the image click on Overscan then the dialog is propmt change the Theme to Holo light the error will disappear.
Image :

Accessing Android Studio properties window?

I have recently started using Android Studio and cannot work out how to access the properties window.
The following screenshot was taken from Google and shows exactly what I'm trying to access denoted by the red rectangle around the properties window.
Can anyone please tell me how I can access this?
Switch to design view. Click "Design" tab at bottom-left work area.
In the new Android Studio Version 3.1.2, the name of the Propierties Windows is "Attributes".
Look at this picture:
Attributes basic view
And, if you want to see the complete attributes, simply click on "View all attributes":
Attributes full view
How to restore windows?:
restore windows
I had the same issue than found that the properties window was always there but I had to drag it out with my mouse. Just go to the far right vertical bar in Design mode then drag to the right when your mouse turns into horizontal arrows pointing away from each other. Hope this helps!
You can just click on the design tab on your screen (at the left bottom corner below your code text window) and just click on anything whose property you want to change
make sure you are in the '.xml' file
I accidentally deleted the properties side bar and Window-->restore deafult layout helped.
Follow the doc.
Instead of editing your view properties in XML, you can do so from the Properties window (on the right side of the Layout Editor). This window is available only when the design editor is open, so be sure you've selected the Design tab at the bottom of the window.
When you select a view, the Properties window shows the following, as indicated in figure 5:
View inspector with controls for width/height style, margins, and bias (available only for views in a ConstraintLayout). For more information, see Build a Responsive UI with ConstraintLayout.
This happens all the time, to my opinion Android team should see as an improvement opportunity, here is the solution, click on the settings (gear symbol) on the right make sure that the attached side is set to None. also -See screen shot-> 1,
You have three ways to see the fields, design mode, split mode and code mode. THE ONLY ONE THAT shows the Attribute bar is on the SPLIT MODE, click on the Attribute see screenshot->
if that does not work, you can go to Windows -> Restore default Layout
if that still does not work you can do File -> Manage IDE Settings -> Restore Default Settings.
if that still does not work you can go in file explorer and delete the .android studio folder in C\users[your user].Androidstudio#.#
Hope this helps someone out there...

Why "Buttons in button bars should be borderless" in Android API Level 15?

I'm developing an application for Android and I recently changed the API level target from 8 to 15, and now Eclipse is warning me when the Buttons are inside Linear Layouts or Table Rows.
The same doesn't happen when the Button is in a Relative Layout.
The warning says:
Buttons in button bars should be borderless; use
style="?android:attr/buttonBarButtonStyle" (and
?android:attr/buttonBarStyle on the parent)
I can get rid of the warning by following the suggestion or even by suppressing it, but I'm interested to know why this now? What's wrong with bordered buttons?
The borderless buttons are for cohesiveness of design throughout the android platform. It's recommended you follow the guidelines so that the user feels that your app is native and does not stick out like a sore thumb, but there are many cases where it just doesn't make sense, like if it makes your app look unprofessional. If that is the case, you may want to turn off the warning.
To turn off the warning, go to the project properties -> Android Lint Preferences. Search for "border" or "ButtonStyle" and change the severity to ignore on the bottom right.
You can also do this in Eclipse preferences for all projects.
For Android Studio Users:
File -> Settings -> Editor -> Inspections -> Android Lint. Search for "borderless" and uncheck or change the severity.
Here is another simple way to get rid of it.
The compiler is trying to tell you to set the style of the button. So simply add the following style for the Android default borderless style and the error will be gone.
<Button
...
style="?android:attr/borderlessButtonStyle"/>
Here is the proof
In my case adding that style to ALL buttons which were ONLY elements in some linerar layout gave buttons without any borders. After adding style also to the layout I got buttons separated with small edges exsacly like in some epements of my (4.1.2) android interface eg. like in dialog possitive/negative buttons. It worked correctly. Standard Holo buttons are ugly but with that styles they look "professional";-)
You can add this code to fix it " style="?android:attr/borderlessButtonStyle"/> "
but if your emulator is too old then that problem can occur aswell.Try to change your emulator Pixel 6 Pro.

Categories

Resources