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).
Related
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"
Recently I’ve upgraded from Android Studio 1 to Android Studio Beta 1.2.
And among other issues, it seems that the shortcut (Option + Command + L) for formatting the xml-layouts it doesn’t reorganice code any more.
In the previous version of Android Studio, if you had something like this:
<RelativeLayout
android:layout_alignParentLeft="true"
android:layout_margin="#dimen/_10dp"
android:id="#+id/rl_avatar"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
After formatting you got the next result:
<RelativeLayout
android:id="#+id/rl_avatar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_margin="#dimen/_10dp">
But now I just get this message: “No lines changed. Code is already properly formatted”
Is there any kind of configuration that I’m missing it?
Thanks!
Try Ctrl+Shift+Alt+L, you should have a dialog where you can tick "Rearrange".
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
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
I faced this strange problem.
On my layout xml, I have a single TextView, and in it I have the following text:
"Welcome to App.\n etc" , defined in strings.xml.
In a tablet running 4.0 displays the full string.
In a smartphone running 2.3.7 it displays just before the \n.
On previous apps I have created, \n worked okay.
Anybody faced something similar?
XML Code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="#+id/textViewWelcomeNotes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="false"
android:layout_centerHorizontal="true"
android:layout_centerVertical="false"
android:layout_margin="15dp"
android:layout_marginTop="20dp"
android:fitsSystemWindows="false"
android:focusableInTouchMode="true"
android:gravity="center_vertical|center_horizontal"
android:hint="#string/msgWelcomeNotesHint"
android:paddingTop="10dp"
android:text="#string/msgWelcomeNotes"
android:textSize="14dp" />
</RelativeLayout>
It was a weird bug of latest ADT 20.0, in Eclipse Juno.
I made a fresh install of Eclipse Juno, because i heavily loaded it with plugins,
and now \n appears okay, in the same apk, on 2.3 and 4.0+ Android Versions.
Also some other bugs, eg when creating new activity (New->Other->Android Activity), exist on this ADT.