当前位置: 代码迷 >> Android >> android页面格局
  详细解决方案

android页面格局

热度:59   发布时间:2016-05-01 18:46:33.0
android页面布局
主页面
package com.dongyin.cn;

import com.dongyin.cn.activity.LocationOfGis;
import com.dongyin.cn.activity.TaskOfDay;
import com.dongyin.cn.activity.WorkOfCamera;
import com.dongyin.cn.activity.addview.ReturnView;

import android.app.ActivityGroup;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TableLayout;

public class WorkspaceActivity extends ActivityGroup {
//右边工作页面
private LinearLayout container = null;
//左边按钮
private Button btnFirst;
private Button btnSecond;
private Button btnThird;
//任务隐藏界面
private TableLayout leftTask;//今日任务
private Button taskAll;//所有任务
//相机隐藏界面
private TableLayout cameraStart;//开始拍照
private Button cameraOpen;//打开相机
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 隐藏标题栏  
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        //强制为横屏
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        setContentView(R.layout.workspace);
        //alpha="0.5"
        //事件
        leftClickInfo();
}
//左边事件
public void leftClickInfo()
{
//右边显示页面
container=(LinearLayout)findViewById(R.id.containerBody);
//左边按钮
btnFirst=(Button)findViewById(R.id.btnFirst);
btnSecond=(Button)findViewById(R.id.btnSecond);
btnThird=(Button)findViewById(R.id.btnThird);
//任务隐藏界面
leftTask=(TableLayout)findViewById(R.id.leftTask);
taskAll=(Button)findViewById(R.id.taskAll);
//相机隐藏界面
cameraStart=(TableLayout)findViewById(R.id.cameraStart);
cameraOpen=(Button)findViewById(R.id.cameraOpen);

//任务模块
btnFirst.setOnClickListener(
new OnClickListener()
{
@Override
public void onClick(View v) {
//判断是否隐藏
if(leftTask.getVisibility()==TableLayout.GONE)
{
leftTask.setVisibility(TableLayout.VISIBLE);
cameraStart.setVisibility(TableLayout.GONE);
}else{
leftTask.setVisibility(TableLayout.GONE);
}
}
}
);
//查看任务
taskAll.setOnClickListener(
new OnClickListener()
{
@Override
public void onClick(View v) {
container.removeAllViews();
Intent intent=new Intent(WorkspaceActivity.this,TaskOfDay.class);
Window windowTask=getLocalActivityManager().startActivity("windowTask", intent);
container.addView(windowTask.getDecorView());
}
}
);
//位置模块
btnSecond.setOnClickListener(
new OnClickListener()
{
@Override
public void onClick(View v) {
container.removeAllViews();
Intent intent=new Intent(WorkspaceActivity.this,LocationOfGis.class);
Window windowSecond=getLocalActivityManager().startActivity("windowSecond", intent);
container.addView(windowSecond.getDecorView());
}
}
);
//相机模块
btnThird.setOnClickListener(
new OnClickListener()
{
@Override
public void onClick(View v) {
//判断是否隐藏
if(cameraStart.getVisibility()==TableLayout.GONE)
{
leftTask.setVisibility(TableLayout.GONE);
cameraStart.setVisibility(TableLayout.VISIBLE);
}else{
cameraStart.setVisibility(TableLayout.GONE);
}
}
}
);
//打开相机
cameraOpen.setOnClickListener(
new OnClickListener()
{
@Override
public void onClick(View v) {
container.removeAllViews();
Intent intent=new Intent(WorkspaceActivity.this,WorkOfCamera.class);
Window windowCamera=getLocalActivityManager().startActivity("windowCamera", intent);
container.addView(windowCamera.getDecorView());
// Intent intent=new Intent(WorkspaceActivity.this,ReturnView.class);
// Window windowReturn=getLocalActivityManager().startActivity("windowReturn", intent);
// container.addView(windowReturn.getDecorView());
}
}
);
}
}
xml页面
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:background="@drawable/tianlanse"
  android:orientation="horizontal"
  >
    <LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="300dip"
  android:layout_height="match_parent"
  android:orientation="vertical"
  >
      <TextView
      android:textColor="@android:color/black"
      android:text=""
      android:background="@drawable/main_63"
      android:textSize="30dip"
        android:layout_width="300dip"
        android:layout_height="50dip"
        />
    <TableLayout
    android:id="@+id/firstRow"
        android:orientation="vertical" 
        android:layout_width="300dip"
        android:layout_height="fill_parent"
        >
        <!-- 功能模块按钮1 -->  
        <TableRow
        android:orientation="vertical"
        >
        <Button
        android:id="@+id/btnFirst"
        android:layout_width="300dip"
        android:layout_height="100dip"
        android:textSize="30dip"
        android:textColor="@android:color/black"
        android:text=""
        />
        </TableRow> 
        <TableRow>
        <!-- 第一隐藏界面 -->
        <TableLayout
    android:id="@+id/leftTask"
        android:orientation="vertical"
        android:visibility="gone"
        android:layout_height="wrap_content"
        android:layout_width="300dip" >
        <TableRow>
        <Button
        android:id="@+id/taskAll"
        android:layout_width="300dip"
        android:layout_height="wrap_content"
        android:textColor="@android:color/black"
        android:text=""
        />
        </TableRow>
        </TableLayout>
        </TableRow>
        <!-- 功能模块按钮2 -->  
        <TableRow
        android:layout_width="300dip" 
        android:layout_height="100dip">
        <Button android:id="@+id/btnSecond"
            android:layout_width="300dip" 
            android:layout_height="100dip"
            android:textSize="30dip"
            android:textColor="@android:color/black"
            android:text=""
            />
        </TableRow>
        <!-- 功能模块按钮3 --> 
        <TableRow
        android:layout_width="300dip" 
        android:layout_height="100dip">
        <Button android:id="@+id/btnThird"
            android:layout_width="300dip" 
            android:layout_height="100dip"
            android:textSize="30dip"
            android:textColor="@android:color/black"
            android:text=""
            />
        </TableRow>
        <TableRow>
        <!-- 第三隐藏界面 -->
        <TableLayout
    android:id="@+id/cameraStart"
        android:orientation="vertical"
        android:visibility="gone"
        android:layout_height="wrap_content"
        android:layout_width="300dip" >
        <TableRow>
        <Button
        android:id="@+id/cameraOpen"
        android:layout_width="300dip"
        android:layout_height="wrap_content"
        android:textColor="@android:color/black"
        android:text=""
        />
        </TableRow>
        </TableLayout>
        </TableRow>
    </TableLayout> 
    </LinearLayout>
    <!-- 中间动态加载Activity -->
    <LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="980dip"
  android:layout_height="match_parent"
  android:orientation="vertical"
  >
  <TextView
  android:textColor="@android:color/black"
  android:text=""
  android:background="@drawable/main_63"
  android:textSize="30dip"
  android:layout_width="980dip"
  android:layout_height="50dip"
  />
    <LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/containerBody"
  android:layout_width="980dip"
  android:layout_height="match_parent"
  android:orientation="vertical"
  >
  </LinearLayout>
  </LinearLayout>
</LinearLayout>
  相关解决方案