Layout file: res/layout/activity_my.xml
Copy codeThe Code is as follows: [html] <LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android"
Xmlns: tools = "http://schemas.android.com/tools"
Android: id = "@ + id/LinearLayout"
Android: layout_width = "fill_parent"
Android: layout_height = "fill_parent"
Android: orientation = "horizontal"
Tools: context = ". MyActivity">
<Button
Android: id = "@ + id/button1"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: layout_weight = "1"
Android: text = "@ string/wo"
Android: textColorHint = "@ color/calamus"/>
<Button
Android: id = "@ + id/button2"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: layout_weight = "1"
Android: text = "@ string/shi"/>
<Button
Android: id = "@ + id/button3"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: layout_weight = "1"
Android: text = "@ string/hao"
Android: textColor = "@ color/calamus"/>
<Button
Android: id = "@ + id/button4"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: layout_weight = "1"
Android: text = "@ string/ren"/>
</LinearLayout>
<LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android"
Xmlns: tools = "http://schemas.android.com/tools"
Android: id = "@ + id/LinearLayout"
Android: layout_width = "fill_parent"
Android: layout_height = "fill_parent"
Android: orientation = "horizontal"
Tools: context = ". MyActivity">
<Button
Android: id = "@ + id/button1"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: layout_weight = "1"
Android: text = "@ string/wo"
Android: textColorHint = "@ color/calamus"/>
<Button
Android: id = "@ + id/button2"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: layout_weight = "1"
Android: text = "@ string/shi"/>
<Button
Android: id = "@ + id/button3"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: layout_weight = "1"
Android: text = "@ string/hao"
Android: textColor = "@ color/calamus"/>
<Button
Android: id = "@ + id/button4"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: layout_weight = "1"
Android: text = "@ string/ren"/>
</LinearLayout>
Resource file: res/values/strings. xmlCopy codeThe Code is as follows: [html] view plaincopyprint? <? Xml version = "1.0" encoding = "UTF-8"?>
<Resources>
<String name = "app_name"> Linear </string>
<String name = "action_settings"> Settings </string>
<String name = "wo"> mE </string>
<String name = "shi"> Yes </string>
<String name = "hao"> good </string>
<String name = "ren"> Persons </string>
</Resources>
<? Xml version = "1.0" encoding = "UTF-8"?>
<Resources>
<String name = "app_name"> Linear </string>
<String name = "action_settings"> Settings </string>
<String name = "wo"> mE </string>
<String name = "shi"> Yes </string>
<String name = "hao"> good </string>
<String name = "ren"> Persons </string>
</Resources>
Resource file: res/values/styles. xmlCopy codeThe Code is as follows: [html] view plaincopyprint? <Resources>
<! --
Base application theme, dependent on API level. This theme is replaced
By AppBaseTheme from res/values-vXX/styles. xml on newer devices.
-->
<Style name = "AppBaseTheme" parent = "android: Theme. Light">
<! --
Theme customizations available in newer API levels can go in
Res/values-vXX/styles. xml, while customizations related
Backward-compatibility can go here.
-->
</Style>
<! -- Application theme. -->
<Style name = "AppTheme" parent = "AppBaseTheme">
<! -- All mizmizations that are NOT specific to a special API-level can go here. -->
</Style>
<Color name = "calamus"> # c77eb5 </color>
</Resources>
<Resources>
<! --
Base application theme, dependent on API level. This theme is replaced
By AppBaseTheme from res/values-vXX/styles. xml on newer devices.
-->
<Style name = "AppBaseTheme" parent = "android: Theme. Light">
<! --
Theme customizations available in newer API levels can go in
Res/values-vXX/styles. xml, while customizations related
Backward-compatibility can go here.
-->
</Style>
<! -- Application theme. -->
<Style name = "AppTheme" parent = "AppBaseTheme">
<! -- All mizmizations that are NOT specific to a special API-level can go here. -->
</Style>
<Color name = "calamus"> # c77eb5 </color>
</Resources>
Resource Index File R. javaCopy codeThe Code is as follows: [java] view plaincopyprint? /* AUTO-generated file. do not modify.
*
* This class was automatically generated by
* Aapt tool from the resource data it found. It
* Shoshould not be modified by hand.
*/
Package com. eirc. linear;
Public final class R {
Public static final class attr {
}
Public static final class color {
Public static final int calamus = 0x7f070000;
}
Public static final class dimen {
/** Default screen margins, per the Android Design guidelines.
Customize dimensions originally defined in res/values/dimens. xml (such
Screen margins) for sw720dp devices (e.g. 10 "tablets) in landscape here.
*/
Public static final int activity_horizontal_margin = 0x7f040000;
Public static final int activity_vertical_margin = 0x7f040001;
}
Public static final class drawable {
Public static final int ic_launcher = 0x7f020000;
}
Public static final class id {
Public static final int LinearLayout = 0x7f090000;
Public static final int action_settings = 0x7f090005;
Public static final int button1 = 0x7f090001;
Public static final int button2 = 0x7f090002;
Public static final int button3 = 0x7f090003;
Public static final int button4 = 0x7f090004;
}
Public static final class layout {
Public static final int activity_my = 0x7f030000;
}
Public static final class menu {
Public static final int my = 0x7f080000;
}
Public static final class string {
Public static final int action_settings = 0x7f050001;
Public static final int app_name = 0x7f050000;
Public static final int hao = 0x7f050004;
Public static final int ren = 0x7f050005;
Public static final int shi = 0x7f050003;
Public static final int wo = 0x7f050002;
}
Public static final class style {
/**
Base application theme, dependent on API level. This theme is replaced
By AppBaseTheme from res/values-vXX/styles. xml on newer devices.
Theme customizations available in newer API levels can go in
Res/values-vXX/styles. xml, while customizations related
Backward-compatibility can go here.
Base application theme for API 11 +. This theme completely replaces
AppBaseTheme from res/values/styles. xml on API 11 + devices.
API 11 theme customizations can go here.
Base application theme for API 14 +. This theme completely replaces
AppBaseTheme from BOTH res/values/styles. xml and
Res/values-v11/styles. xml on API 14 + devices.
API 14 theme customizations can go here.
*/
Public static final int AppBaseTheme = 0x7f060000;
/** Application theme.
All mizmizations that are NOT specific to a special API-level can go here.
*/
Public static final int AppTheme = 0x7f060001;
}
}
/* AUTO-generated file. do not modify.
*
* This class was automatically generated by
* Aapt tool from the resource data it found. It
* Shoshould not be modified by hand.
*/
Package com. eirc. linear;Copy codeThe Code is as follows: public final class R {
Public static final class attr {
}
Public static final class color {
Public static final int calamus = 0x7f070000;
}
Public static final class dimen {
/** Default screen margins, per the Android Design guidelines.
Customize dimensions originally defined in res/values/dimens. xml (such
Screen margins) for sw720dp devices (e.g. 10 "tablets) in landscape here.
*/
Public static final int activity_horizontal_margin = 0x7f040000;
Public static final int activity_vertical_margin = 0x7f040001;
}
Public static final class drawable {
Public static final int ic_launcher = 0x7f020000;
}
Public static final class id {
Public static final int LinearLayout = 0x7f090000;
Public static final int action_settings = 0x7f090005;
Public static final int button1 = 0x7f090001;
Public static final int button2 = 0x7f090002;
Public static final int button3 = 0x7f090003;
Public static final int button4 = 0x7f090004;
}
Public static final class layout {
Public static final int activity_my = 0x7f030000;
}
Public static final class menu {
Public static final int my = 0x7f080000;
}
Public static final class string {
Public static final int action_settings = 0x7f050001;
Public static final int app_name = 0x7f050000;
Public static final int hao = 0x7f050004;
Public static final int ren = 0x7f050005;
Public static final int shi = 0x7f050003;
Public static final int wo = 0x7f050002;
}
Public static final class style {
/**
Base application theme, dependent on API level. This theme is replaced
By AppBaseTheme from res/values-vXX/styles. xml on newer devices.
Theme customizations available in newer API levels can go in
Res/values-vXX/styles. xml, while customizations related
Backward-compatibility can go here.
Base application theme for API 11 +. This theme completely replaces
AppBaseTheme from res/values/styles. xml on API 11 + devices.
API 11 theme customizations can go here.
Base application theme for API 14 +. This theme completely replaces
AppBaseTheme from BOTH res/values/styles. xml and
Res/values-v11/styles. xml on API 14 + devices.
API 14 theme customizations can go here.
*/
Public static final int AppBaseTheme = 0x7f060000;
/** Application theme.
All mizmizations that are NOT specific to a special API-level can go here.
*/
Public static final int AppTheme = 0x7f060001;
}
}
Activity:Copy codeThe Code is as follows: [java] view plaincopyprint? Package com. eirc. linear;
Import android. OS. Bundle;
Import android. app. Activity;
Import android. view. Menu;
Public class MyActivity extends Activity {
@ Override
Protected void onCreate (Bundle savedInstanceState ){
Super. onCreate (savedInstanceState );
SetContentView (R. layout. activity_my );
}
@ Override
Public boolean onCreateOptionsMenu (Menu menu ){
// Inflate the menu; this adds items to the action bar if it is present.
GetMenuInflater (). inflate (R. menu. my, menu );
Return true;
}
}
Package com. eirc. linear;Copy codeThe Code is as follows: import android. OS. Bundle;
Import android. app. Activity;
Import android. view. Menu;
Public class MyActivity extends Activity {
@ Override
Protected void onCreate (Bundle savedInstanceState ){
Super. onCreate (savedInstanceState );
SetContentView (R. layout. activity_my );
}
@ Override
Public boolean onCreateOptionsMenu (Menu menu ){
// Inflate the menu; this adds items to the action bar if it is present.
GetMenuInflater (). inflate (R. menu. my, menu );
Return true;
}
}
Final effect: