Downgrade SDK and build target android - 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!!

Related

ConstraintLayout doesn't match with the screen size

I just started my first Android Studio project and I already come with a problem :)
I search on google for the answer but didn't find my problem.
So I need your help please ^^
I download the last version of Android Studio, create a project with an Empty Activity and I came up with this
As you can see my ConstraintLayout is really small and I just can't work with this.
I didn't touch anything on the project. Just to be sure I create 3 projects that have the same issue and redownload 4 time Android Studio.
On the virtual Devices, it looks correct throw: Screenshot
I put the XML code just in case it can help
xmlcode
Hope I was clear and sorry for my English ;)
EDIT: For some reason, the constraint layout fit correctly on the watch screen, but I don't want to create a watch app x) screenshot_watchview
Ok so I have finally find the problem ! I'm so happy right now :D
The problem was the AppTheme theme that I use, I switch it with the DeviceDefault theme. I don't know why this theme was causing problem but now it work and I can finally work on my first Android App !
If you are using the supportLibrary 28+ then this thing happened to me too.
and when I change the support lib version to the 27, it works.
Maybe this is a possible bug in the support library 28+.
Changing the AppTheme works like a charm if you want to stick with the support library 28+ But if you still don't want to so Try using the support library below 28.

Android Studio XML using marginRight with API 17

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.

Percent Relative Layout with Android Nougat

I used percent relative layout in my project. It working good under android 7.
But I tested with nougat. Its not working.
Waiting Your Helps.
As documentation says, after Oreo(maybe you are using the 26 SDK?) it's deprecated, you will need to use ConstraintLayout
https://developer.android.com/reference/android/support/percent/PercentRelativeLayout.html
Hope this helps

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.

Android Studio sometimes using the deprecated ''fill_parent'

I just downloaded Android Studio May 10, 2014 and started using the rich layout editor.
I noticed that when I would drag and drop a RelativeLayout, Android Studio would automatically use fill_parent for both the layout_width and the layout_height attributes.
Why does Android Studio not fill in the non-deprecated value, match_parent by default?
It has been filed as a bug but has not yet been confirmed. You can see the bug report here.
Because it's in alpha stage of development :)

Categories

Resources