布局文件:res/layout/activity_my.xml
复制代码 代码如下:
[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>
资源文件:res/values/strings.xml
复制代码 代码如下:
[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">我</string>
<string name="shi">是</string>
<string name="hao">好</string>
<string name="ren">人</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">我</string>
<string name="shi">是</string>
<string name="hao">好</string>
<string name="ren">人</string>
</resources>
资源文件:res/values/styles.xml
复制代码 代码如下:
[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 to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="Apptheme" parent="AppBasetheme">
<!-- All customizations that are NOT specific to a particular 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 to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="Apptheme" parent="AppBasetheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
<color name="calamus">#c77eb5</color>
</resources>
资源索引文件R.java
复制代码 代码如下:
[java] vIEw plaincopyprint?/* auto-GENERATED file. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should 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 as
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 to
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 customizations that are NOT specific to a particular API-level can go here.
*/
public static final int Apptheme=0x7f060001;
}
}
/* auto-GENERATED file. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should 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 as
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 to
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 customizations that are NOT specific to a particular API-level can go here.
*/
public static final int Apptheme=0x7f060001;
}
}
Activity:
复制代码 代码如下:
[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;
复制代码 代码如下:
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;
}
}
最终效果:
以上是内存溢出为你收集整理的android 线性布局LinearLayout实例代码全部内容,希望文章能够帮你解决android 线性布局LinearLayout实例代码所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)