Sms Gratis Indosat

Phone Numbers
0 -
Example : 83832867987 Without 0

Type your Messages

Question: + =

Create button with round background

To create button with round background, create /res/drawable/roundbackground.xml to define round background drawable.
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
android:padding="10dp">
<solid android:color="@android:color/background_dark"/>
<corners
android:bottomRightRadius="20dp"
android:bottomLeftRadius="20dp"
android:topLeftRadius="20dp"
android:topRightRadius="20dp"/>
</shape>


Apply "roundbackground" to the background of button.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:padding="@dimen/padding_medium"
android:text="@string/hello_world"
tools:context=".MainActivity" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="@drawable/roundbackground"
android:text="Button with round background"
android:textColor="@android:color/white"
/>

</RelativeLayout>

Button with round background


Creating alias resources

When you have a resource that you'd like to use for more than one device configuration (but do not want to provide as a default resource), you do not need to put the same resource in more than one alternative resource directory. Instead, you can (in some cases) create an alternative resource that acts as an alias for a resource saved in your default resource directory.

Reference: http://developer.android.com/guide/topics/resources/providing-resources.html#AliasResources

Refer to the last exercise of Alternative Resources. Both /res/layout-land/activity_main.xml and /res/layout-large/activity_main.xml have the same layout. We can create alias resources refer to a common xml file.

Create: /res/values-land/refs.xml and /res/values-large/refs.xml.
Both define resource of type="layout" with name="activity_item_list", refer to the same layout file /res/layout/activity_main_horizontal.xml
<resources>
<item type="layout" name="activity_main">@layout/activity_main_horizontal</item>
</resources>


Create the common layout /res/layout/activity_main_horizontal.xml. Actually it's the original /res/layout-land/activity_main.xml and /res/layout-large/activity_main.xml.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:padding="@dimen/padding_medium"
android:src="@drawable/ic_launcher"
tools:context=".MainActivity" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:padding="@dimen/padding_medium"
android:text="@string/myqualifier"
tools:context=".MainActivity" />
</LinearLayout>

</RelativeLayout>


Delete the original duplicated layout, /res/layout-land/activity_main.xml and /res/layout-large/activity_main.xml.

It have the same result of the last exercise, Providing Alternative Resources.

Bentley Mulsanne Diamond Jubilee Edition

V8 / 6.750 cc / 512 PS / 752 lb/ft (1.020 Nm) @ 1.800 / twin turbo / 0 - 62 mph (100 km/h): 5,3 s / Vmax: 184 mph (296 km/h)

(click images for a larger view)










Providing Alternative Resources

App developers can provide alternative resources to support specific device configurations. For instance, you should include alternative drawable resources for different screen densities and alternative string resources for different languages. At runtime, Android detects the current device configuration and loads the appropriate resources for your application.

Reference: http://developer.android.com/guide/topics/resources/providing-resources.html#AlternativeResources

It's a example to provide alternative resources for various configurations.

Galaxy Nexus (4.0.4) in landscape orientation

Galaxy Nexus (4.0.4) in portrait orientation

HTC Flyer (3.2.1) in landscape orientation

HTC Flyer (3.2.1) in portrait orientation


Create a Android Application Project with Build SDK Android 4.1 (API 16) and Minimum Required SDK API 11: Android 3.0 (Honeycomb), select BlankActivity, Navigation Type of None.

Modify/Create resources as list below:

/res/values/strings.xml
<resources>

<string name="app_name">AndroidQualifier</string>
<string name="hello_world">Hello world!</string>
<string name="menu_settings">Settings</string>
<string name="title_activity_main">MainActivity</string>

<string name="myqualifier">DEFAULT qualifier</string>

</resources>


/res/values-land/strings.xml
<resources>
<string name="myqualifier">-land qualifier</string>
</resources>


/res/values-large/strings.xml
<resources>
<string name="myqualifier">-large qualifier</string>
</resources>


/res/values-v11/strings.xml
<resources>
<string name="myqualifier">-v11 qualifier</string>
</resources>


/res/values-v14/strings.xml
<resources>
<string name="myqualifier">-v14 qualifier</string>
</resources>


/res/layout/activity_main.xml, LinearLayout in vertical.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:padding="@dimen/padding_medium"
android:src="@drawable/ic_launcher"
tools:context=".MainActivity" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:padding="@dimen/padding_medium"
android:text="@string/myqualifier"
tools:context=".MainActivity" />
</LinearLayout>

</RelativeLayout>


/res/layout-land/activity_main.xml
/res/layout-large/activity_main.xml, LinearLayout in horizontal.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:padding="@dimen/padding_medium"
android:src="@drawable/ic_launcher"
tools:context=".MainActivity" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:padding="@dimen/padding_medium"
android:text="@string/myqualifier"
tools:context=".MainActivity" />
</LinearLayout>

</RelativeLayout>

In this exercise both /res/layout-land/activity_main.xml and /res/layout-large/activity_main.xml have the same layout. It can defined in one common layout file with alias resources.


 
Copyright © 2015. About - Web Version - Mobile Version Sitemap - Contact - Privacy