How to use paddingStart in old android version? - android

its my layout XML :
<ListView
android:id="#+id/list"
android:paddingLeft="16dip"
android:paddingRight="16dip"
android:paddingStart="16dip"
android:paddingEnd="16dip"
android:scrollbarStyle="outsideOverlay"
android:layout_weight="1"
android:fadingEdge="none"
android:cacheColorHint="#android:color/transparent"
android:divider="#null"
android:listSelector="#android:color/transparent"/>
its work well in android 4.2 ! but when i test it on android 2.2 return this error :
android-apt-compiler: /group_browse_list_fragment.xml:24: error: No resource identifier found for attribute 'paddingStart' in package 'android'
how can i resolve this ?

If you want your app to work with versions earlier than Android 4.2 (the app's targetSdkVersion or minSdkVersion is 16 or less), then you should add “start” and end” in addition to “left” and “right”. For example, you’d use both android:paddingLeft and android:paddingStart.
For more information, check here

Related

appcompat-v7 abc_alert_dialog_material.xml Lint error

my project has android:minSdkVersion="9" and uses appcompat-v7 lib.
When I run Lint, following error is shown:
Multiple annotations found at this line:
- To support older versions than API 17 (project specifies 9) you must also specify gravity or layout_gravity="start"
- Attribute "textAlignment" is only used in API level 17 and higher (current min is 9)
The corresponding code fragment is
<android.support.v7.widget.DialogTitle
android:id="#+id/alertTitle"
style="?attr/android:windowTitleStyle"
android:singleLine="true"
android:ellipsize="end"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="viewStart"/>
Adding android:gravity="start" doesn't help because Gravity.START requires API level 14.
Also there is a Lint error
Call requires API level 11 (current min is 9)
for the following files in v7_appcompat lib:
android:attr/borderlessButtonStyle in notification_media_action.xml
android:attr/borderlessButtonStyle in notification_media_cancel_action.xml
android:attr/dividerHorizontal in notification_template_big_media_narrow.xml
android:attr/dividerHorizontal in notification_template_big_media.xml
What can I do?
use gravity and set left instead of start .
android:gravity="left"

Android versions lower than API Level 21 using appcompat

In the following code, android:progressTint="#c9c9c9", android:secondaryProgressTint="#bebebe" and android:thumbTint="#a9a9a9" are API Level 21 features. However, I am currently using com.android.support:appcompat-v7:23.1.1. Will my app run on devices lower than API 21?
<SeekBar
android:id="#+id/teacher_intro_seekbar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:progress="10"
android:paddingRight="10dp"
android:progressTint="#c9c9c9"
android:secondaryProgressTint="#bebebe"
android:thumbTint="#a9a9a9" />
Yes they will work for API 21 and above, For lower versions they will be ignored. If you want for all versions use app compat seekbar as below.
<android.support.v7.widget.AppCompatSeekBar
android:id="#+id/teacher_intro_seekbar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:progress="10"
android:paddingRight="10dp"
app:progressTint="#c9c9c9"
app:secondaryProgressTint="#bebebe"
app:thumbTint="#a9a9a9" />
It will run, but it may not look correct. XML properties not recognized are ignored. In this case they will definitely be ignored- you aren't using an app compat version of Seekbar, so the compatibility library doesn't matter. (I don't know if there is an app compat version of seekbar, but even if there is you aren't using it).

NestedScroll overlayTop AppBar error

Problem is that just I can't user overlayTop but I've got Support Design Library 23.1 included and every component usable just this one not
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/nes_scroll"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
app:behavior_overlayTop="44dp">
...
and here's error:
Error:(50) No resource identifier found for attribute behavior_overlayTop in package com.scroll.example
also it's not usable in Java source too, it's just red line and offers to create class related to setOverlapTop().

Error while adding text field in Emulator

Whenever I add any TextView in the XML file it shows me the error "Exception raised during rendering: java.lang.System.arraycopy([CI[CII)V".
What is the reasoning behind this?
This is the XML part where the above written error is being shown.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<EditText
android:id="#+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10" >
<requestFocus />
</EditText>
Check the "Android version to use when rendering layouts". Chose any version that does not have "W" at the end . Those versions are for wearable devices.
This problem happened on API 20 (Android 4.4 W). Problem will be solved by changing Android version to use for rendering level form API 20 (Android 4.4 W) to API 19 (Android 4.4.2) (android icon in top right corner of graphical layout) or update your SDK to Android L (API 20 L preview)
Source of answer

How to get "?android:attr/actionBarSize" with Compatibility Library

I'm trying to use Fragments and ActionBar in a Android 2.2 project. There is some error when using "?android:attr/actionBarSize", how to get and set that value correctly?
Example:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/frags">
<fragment class="com.example.android.hcgallery.TitlesFragment"
android:id="#+id/frag_title"
android:visibility="gone"
android:layout_marginTop="?android:attr/actionBarSize"
android:layout_width="#dimen/titles_size"
android:layout_height="match_parent" />
<fragment class="com.example.android.hcgallery.ContentFragment"
android:id="#+id/frag_content"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
Error: No resource found that matches the given name (at 'layout_marginTop' with value '?android:attr/actionBarSize').
You should just use:
android:layout_marginTop="?attr/actionBarSize"
See http://developer.android.com/training/basics/actionbar/overlaying.html
"...The one with the android: prefix is for versions of Android that
include the style in the platform and the one without the prefix is
for older versions that read the style from the Support Library..."
For me replacing
android:layout_marginTop="?android:attr/actionBarSize"
with
android:layout_marginTop="?attr/actionBarSize"
helped to launch app on Android 2.2 and Android 4.3 without any issues.
I think the problem is that actionbar comes with android 3.0 and you are using 2.2. But there is a way to skip this by a extension called "actionbarsherlock".

Categories

Resources