11 android:layout_centerVertical="true" 12 android:layout_centerHorizontal="true" 13 android:textSize="50dp" 14 android:onClick="blinkLED"></ToggleButton> 15 </RelativeLayout> 16/home/phodal/android/app/src/main/res/layout/ledview.xml:14:
11 android:layout_centerVertical="true" 12 android:layout_centerHorizontal="true" 13 android:textSize="50dp" 14 android:onClick="blinkLED"></ToggleButton> 15 </RelativeLayout> 16
onClick
attribute values refer to real methods.onClick
attribute value should be the name of a method in this View's context to invoke when the view is clicked. This name must correspond to a public method that takes exactly one parameter of type View
.1 <manifest xmlns:android="http://schemas.android.com/apk/res/android" 2 package="com.mokcy.hello" android:versionCode="1" android:versionName="1.0"> 3 <uses-feature android:name="android.hardware.usb.accessory" /> 4 <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="15" /> 5 6 <uses-permission android:name="android.permission.INTERNET" />/home/phodal/android/app/src/main/AndroidManifest.xml:4:
1 <manifest xmlns:android="http://schemas.android.com/apk/res/android" 2 package="com.mokcy.hello" android:versionCode="1" android:versionName="1.0"> 3 <uses-feature android:name="android.hardware.usb.accessory" /> 4 <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="15" /> 5 6 <uses-permission android:name="android.permission.INTERNET" />
targetSdkVersion
specifies that it has been tested with, various compatibility modes kick in. This ensures that your application continues to work, but it may look out of place. For example, if the targetSdkVersion
is less than 14, your app may get an option button in the UI.targetSdkVersion
to the highest available value. Then test your app to make sure everything works correctly. You may want to consult the compatibility notes to see what changes apply to each version you are adding support for: http://developer.android.com/reference/android/os/Build.VERSION_CODES.html
10 android:layout_height="150dp" 11 android:layout_centerVertical="true" 12 android:layout_centerHorizontal="true" 13 android:textSize="50dp" 14 android:onClick="blinkLED"></ToggleButton> 15 </RelativeLayout>/home/phodal/android/app/src/main/res/layout/data_view.xml:13:
10 android:layout_height="150dp" 11 android:layout_centerVertical="true" 12 android:layout_centerHorizontal="true" 13 android:textSize="50dp" 14 android:onClick="blinkLED"></ToggleButton> 15 </RelativeLayout>/home/phodal/android/app/src/main/res/layout/ledview.xml:13:
10 android:layout_height="150dp" 11 android:layout_centerVertical="true" 12 android:layout_centerHorizontal="true" 13 android:textSize="50dp" 14 android:onClick="blinkLED"></ToggleButton> 15 </RelativeLayout>/home/phodal/android/app/src/main/res/layout/ledview.xml:13:
10 android:layout_height="150dp" 11 android:layout_centerVertical="true" 12 android:layout_centerHorizontal="true" 13 android:textSize="50dp" 14 android:onClick="blinkLED"></ToggleButton> 15 </RelativeLayout>
dp
instead of sp
dimensions for text sizes.sp
, or "scale-independent pixels". This is like the dp
unit, but it is also scaled by the user's font size preference. It is recommend you use this unit when specifying font sizes, so they will be adjusted for both the screen density and the user's preference.dp
; typically this happens when the text is in a container with a specific dp-size. This will prevent the text from spilling outside the container. Note however that this means that the user's font size settings are not respected, so consider adjusting the layout itself to be more flexible.
4 <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="15" /> 5 6 <uses-permission android:name="android.permission.INTERNET" /> 7 <application android:icon="@drawable/ic_launcher" 8 android:label="@string/app_name" android:theme="@style/AppTheme"> 9 <uses-library android:name="com.android.future.usb.accessory" />/home/phodal/android/app/src/main/AndroidManifest.xml:7:
4 <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="15" /> 5 6 <uses-permission android:name="android.permission.INTERNET" /> 7 <application android:icon="@drawable/ic_launcher" 8 android:label="@string/app_name" android:theme="@style/AppTheme"> 9 <uses-library android:name="com.android.future.usb.accessory" />
true
. When this flag is set to true
, application data can be backed up and restored by the user using adb backup
and adb restore
.adb backup
allows users who have enabled USB debugging to copy application data off of the device. Once backed up, all application data can be read by the user. adb restore
allows creation of application data from a source specified by the user. Following a restore, applications should not assume that the data, file permissions, and directory permissions were created by the application itself.allowBackup="false"
opts an application out of both backup and restore.android:allowBackup=(true|false)"
1 <resources> 2 3 <dimen name="padding_small">8dp</dimen> 4 <dimen name="padding_medium">8dp</dimen> 5 <dimen name="padding_large">16dp</dimen>
5 android:layout_width="fill_parent" 6 android:layout_height="fill_parent" 7 android:padding="10dip" > 8 <LinearLayout 9 android:orientation="vertical" 10 android:layout_height="wrap_content"/home/phodal/android/app/src/main/res/layout/activity_main.xml:8:
5 android:layout_width="fill_parent" 6 android:layout_height="fill_parent" 7 android:padding="10dip" > 8 <LinearLayout 9 android:orientation="vertical" 10 android:layout_height="wrap_content"
textAlignment
attribute to specify text alignment. However, if you are supporting older versions than API 17, you must also specify a gravity or layout_gravity attribute, since older platforms will ignore the textAlignment
attribute.
android:supportsRtl
attribute in the manifest <application>
element.Gravity#LEFT
and Gravity#RIGHT
can lead to problems when a layout is rendered in locales where text flows from right to left. Use Gravity#START
and Gravity#END
instead. Similarly, in XML gravity
and layout_gravity
attributes, use start
rather than left
.layout_marginLeft
, use paddingStart
and layout_marginStart
. NOTE: If your minSdkVersion
is less than 17, you should add both the older left/right attributes as well as the new start/right attributes. On older platforms, where RTL is not supported and the start/right attributes are unknown and therefore ignored, you need the older left/right attributes. There is a separate lint check which catches that type of error.Gravity#LEFT
and Gravity#START
, you can use these constants even when targeting older platforms, because the start
bitmask is a superset of the left
bitmask. Therefore, you can use gravity="start"
rather than gravity="left|start"
.)
<TextView>
is used to display data, the user might want to copy that data and paste it elsewhere. To allow this, the <TextView>
should specify android:textIsSelectable="true"
.minSdkVersion
.
//STOPSHIP
which indicates that code should not be released yet.// STOPSHIP
can be used to flag code that is incomplete but checked in. This comment marker can be used to indicate that the code should not be shipped until the issue is addressed, and lint will look for these.