Android Studio XML using marginRight with API 17 - android

I have a RelativeLayout and I am using android:layout_marginEnd="170dp"
and Android Studio is telling me:
To support older version than API 17(project specifies 15) you should
also add
android:layout_marginRight="170dp"
It's not an error, it compiles correctly, but I don't understand this hint. Why should I use marginRight? Why not marginLeft?
Can anyone explain me the secret behind this?
I looked for other answers but I still didn't get it.
Thank you in advance.

android:layout_marginEnd was added in API 17 for better support for right-to-left languages. However, earlier versions of Android prior to API 17 don't recognize this tag, so your need to add android:layout_marginRight as well.

Related

How to add textDirection support to API 8?

I want to create an Android app using API 8
<uses-sdk android:minSdkVersion="8"/>
I have a EditText control in which I want to type in right-to-left mode.
There is a new property called textDirection which is support in API 17 and higher. But I want to know if there is anyway to make my app supports this property. I heard about some appcompat things but I couldn't figure out if android-support-v7-appcompat has something to do with it.
Will android-support-v7-appcompat solve my problem? cause I tried that and also Adding android.support.v4 to your Android application in IntelliJ IDEA. but none solved my problem.
Is there any other way to do it?

error in styles in API8 in Eclipse

could anyone please help me with this?
I opened an existing project and I get this error in the screenshot.
The problem is that you are using a style which require API 21. You are referencing a style called Widget.Material.ActionButton. So you need to put this reference in a v21 directory to use the CompatLibrary which I would recommend.
The real cause seems to be that you have a very low target SDK (like you wrote in the comments API 8). You should set it to the most newest one, it cannot break anything. So set the target SDK to API 21 or newer and it should work fine.

Classes could not be instantiated: Android Studio Rendering Problems API 22

Whenever I create a blank activity layout file assigned to be rendered at API level 22, following error message is generated
The solution to this is to change the API level by changing it to API 21 or less.
What is the reason behind this?.
This was very common for me when a new API SDK version was released and yes like you mention we have to change the Android version to use when rendering layout in the IDE.
But this time i have installed all the elements described in the Android SDK Manager for this API 22 and I have no problems with the rendering.
You can just change "AppTheme" to another theme and keep the API level as you desire.
Many users are reporting this problem and it happens only in the Layout files that uses support libraries and not the normal ones.

Conflicting lint messages regarding paddingStart usage

After API 17 / RTL support was released, I added the following to my manifest
android:supportsRtl="true"
which caused Lint to rightfully give me these warnings wherever I had paddingLeft/Right in my views:
Consider adding android:paddingStart="8dp" to better support right-to-left layouts
Consider adding android:paddingEnd="8dp" to better support right-to-left layouts
I did this following the guidance found in this android-developers blogpost, which implied that we did not need to create a new layout-v17 file, but rather could just use both the paddingStart/End as well as the paddingLeft/Right attributes (the Left/Right were required to continue supporting a lower minSdk).
I just made the update to Android Studio 1.0 from the previous Beta version, and am noticing a new lint error which states:
Attribute paddingStart referenced here can result in a crash on some specific devices older than API 17 (current min is 7)
and the suggested fix is:
Override Resource in layout-v17
Which makes sense. However, after creating layout-v17 and removing the unused paddingStart/End from the main layout folder, the original Lint warnings have reappeared saying that I should use paddingStart/End. It seems like it does not understand that I have overrided the files in layout-v17.
Does anyone know how to solve what seems to be conflicting Lint error/warning messages? I know I can just tools:ignore the warning, but I am hoping for a "proper" solution.
Edit (1/19/15): There is an android issue that I imagine led to the new lint error being added to Android Studio. This suggests that the "crash on some specific devices" refers to a handful of Samsung tablets on API16 where paddingStart has its own definition and as such crashes when it tries to parse "8dp".
Some people in the above link have suggested to use the layout-ldrtl folder to handle the rtl direction, rather than using paddingStart and paddingEnd.
I've also had a suggestion elsewhere to override the LayoutInflator's Factory2 whenever you find that the user has a API16 tablet, and then manually set the attributes of all your views. This will certainly work, but it seems extremely "manual".
I unfortunately don't have access to one of these devices that crash, so I can't verify why I have not found anyone online suggesting simply putting paddingStart in /layout-v17/ folder, and paddingLeft in /layout/? Do the API16 Samsung tablets somehow still continue to crash despite paddingStart only being present in layout-v17?
You're right about the root cause of the issue - Samsung defined a custom attribute for the id reserved for paddingStart or paddingEnd.
The way I by-passed this was to extract the padding properties and put them into a style. So instead of having different layouts for SDK<17 and SDK>=17, I have different styles for them (with paddingLeft&Right in values and paddingStart&End in values-v17).
This way, Lint will stop complaining about it.
Its just a suggestion. I hope you have solved your problem by now.
If you set your minimum SDK level below 4.1, then you have to explicitly mention the padding as paddingLeft and paddingStart. For SDK level above 4.1, you can use paddingStart. I am guessing (as I have never faced it before), as you set your SDK level to 2.2 or below 4.1, android sdk level is going crazy.

Downgrade SDK and build target android

I'm almost done with my app, and, i admit i made a mistake. I set the min build target a 2.3.1 at the begining and now, i want to downgrade it to 2.1 at least. Everything looks fine except in xml files. i got this :
error: Error: String types not allowed (at 'layout_width' with value 'match_parent').
My question is quite simple : anyone know how can i fix that ? I don't think minSDK 7 refuses the "match parent", but maybe i'm wrong.
Thanks in advance ;)
Change match_parent to fill_parent.
Try to use fill_parent instead of match_parent.Hope this will work for you.match_parent is replaced by fill_parent for some higher version(Exact version from which it is deprecated I don't know).
I tried in sdk 2.1 and match_parent is not working but in Google API 2.1 sdk match_parent is working so you can change the sdk version to Google API 2.1 and then test if it is working in real device if yes then match_parent will works fine otherwise change the match_parent to fill_parent
hope it will help!!

Categories

Resources