Demo06:LinearLayout

来源:互联网 发布:中银淘宝卡办理 编辑:程序博客网 时间:2024/06/07 10:22
package com.wuqiong.demo06;import android.app.Activity;import android.os.Bundle;import android.view.Menu;import android.view.MenuItem;public class MainActivity extends Activity {    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);    }    @Override    public boolean onCreateOptionsMenu(Menu menu) {        // Inflate the menu; this adds items to the action bar if it is present.        getMenuInflater().inflate(R.menu.main, menu);        return true;    }    @Override    public boolean onOptionsItemSelected(MenuItem item) {        // Handle action bar item clicks here. The action bar will        // automatically handle clicks on the Home/Up button, so long        // as you specify a parent activity in AndroidManifest.xml.        int id = item.getItemId();        if (id == R.id.action_settings) {            return true;        }        return super.onOptionsItemSelected(item);    }}

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent"android:orientation="vertical" ><LinearLayout    android:layout_width="match_parent"    android:layout_height="0dp"    android:layout_weight="1"    android:orientation="horizontal" >    <TextView         android:id="@+id/text_view1"        android:layout_width="0dp"        android:layout_height="match_parent"        android:layout_weight="1"        android:background="#aa0000"        android:text="red"/>    <TextView         android:id="@+id/text_view2"        android:layout_width="0dp"        android:layout_height="match_parent"        android:layout_weight="1"        android:background="#00aa00"        android:text="green"/>    <TextView         android:id="@+id/text_view3"        android:layout_width="0dp"        android:layout_height="match_parent"        android:layout_weight="1"        android:background="#0000aa"        android:text="blue"/>    <TextView         android:id="@+id/text_view4"        android:layout_width="0dp"        android:layout_height="match_parent"        android:layout_weight="1"        android:background="#aaaa00"        android:text="yellow"/></LinearLayout><LinearLayout    android:layout_width="match_parent"    android:layout_height="0dp"    android:layout_weight="1"    android:orientation="vertical" >    <TextView         android:id="@+id/text_view5"        android:layout_width="match_parent"        android:layout_height="0dp"        android:layout_weight="1"        android:textSize="30sp"        android:text="row one" />    <TextView         android:id="@+id/text_view6"        android:layout_width="match_parent"        android:layout_height="0dp"        android:layout_weight="1"        android:textSize="30sp"        android:text="row two" />    <TextView         android:id="@+id/text_view7"        android:layout_width="match_parent"        android:layout_height="0dp"        android:layout_weight="1"        android:textSize="30sp"        android:text="row three" />    <TextView         android:id="@+id/text_view8"        android:layout_width="match_parent"        android:layout_height="0dp"        android:layout_weight="1"        android:textSize="30sp"        android:text="row four" /></LinearLayout></LinearLayout>

0 0
原创粉丝点击