1、新建工程
2、建好工程后,修改代码activity_main.xml如下
-
<LinearLayout xmlns:android=""
-
xmlns:tools=""
-
android:orientation="vertical"
-
android:layout_width="fill_parent"
-
android:layout_height="fill_parent"
-
tools:context="${relativePackage}.${activityClass}" >
-
-
<TextView
-
android:layout_width="fill_parent"
-
android:layout_height="wrap_content"
-
android:text="@string/text_one" />
-
<TextView
-
android:layout_width="fill_parent"
-
android:layout_height="wrap_content"
-
android:text="@string/text_two" />
-
-
</LinearLayout>
修改strings.xml如下:
-
<?xml version="1.0" encoding="utf-8"?>
-
<resources>
-
-
<string name="app_name">linearlayout</string>
-
<string name="text_one">text one!</string>
-
<string name="text_two">text two!</string>
-
-
</resources>
代码MainActivity.java如下:
-
package com.example.linearlayout;
-
-
import android.app.Activity;
-
import android.os.Bundle;
-
-
public class MainActivity extends Activity {
-
-
@Override
-
protected void onCreate(Bundle savedInstanceState) {
-
super.onCreate(savedInstanceState);
-
setContentView(R.layout.activity_main);
-
}
-
}
3、运行效果:
阅读(1915) | 评论(0) | 转发(0) |