app开发myapplicaion2

app开发myapplicaion2

image

 

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myapplication">
    <!-- 必须添加网络访问权限 -->
    <uses-permission android:name="android.permission.INTERNET" />
    <!-- 如果需要获取网络状态(可选) -->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"

          android:theme="@style/AppTheme.NoActionBar">

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".SocketActivity" />
    </application>

</manifest>
package com.example.myapplication;

import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;

import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;

import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.VibrationEffect;
import android.os.Vibrator;
import android.util.Log;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import java.io.BufferedReader;
import java.io.Console;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;



public class MainActivity extends AppCompatActivity {
                private EditText et_socket; //发送内容
                private static TextView tv_socket; //recv msg
                private MessageTransmit mTransmit;//声明一个消息传输对象

    // 获取 Vibrator 服务实例

    String  msg_front = "rbt_front";
    String  msg_back = "rbt_back";
    String  msg_left = "rbt_left";
    String  msg_right = "rbt_right";

    String  rbt_huishou = "rbt_huishou";
    String  rbt_jingli = "rbt_jingli";
    String  rbt_woshou = "rbt_woshou";
    String  rbt_jushou = "rbt_jushou";

    String  rbt_jiewu = "rbt_jiewu";
    String  rbt_balei = "rbt_balei";
    String  rbt_jixiewu = "rbt_jixiewu";
    String  rbt_disike = "rbt_disike";
     Vibrator vibrator = null;
    int power_counter  = 1;
                @Override
                protected void onCreate(Bundle savedInstanceState) {
                    super.onCreate(savedInstanceState);

                    // 强制横屏
                    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
                    // 隐藏标题栏
                    supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
                    // 隐藏状态栏
                    getWindow().setFlags(
                            WindowManager.LayoutParams.FLAG_FULLSCREEN,
                            WindowManager.LayoutParams.FLAG_FULLSCREEN
                    );
                  // final Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
                    vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
                    // 全屏核心代码
//        View decorView = getWindow().getDecorView();
//        int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN  // 隐藏状态栏
//                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION  // 隐藏导航栏
//                | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;  // 粘性沉浸式(滑动临时显示,自动隐藏)
//        decorView.setSystemUiVisibility(uiOptions);
//
//        // 隐藏标题栏
//        if (getSupportActionBar() != null) {
//            getSupportActionBar().hide();
//        }
                    setContentView(R.layout.activity_main);
                    // Toolbar toolbar = findViewById(R.id.toolbar);
                    // setSupportActionBar(toolbar);

                    // FloatingActionButton fab = findViewById(R.id.fab);
                    //  fab.setOnClickListener(new View.OnClickListener() {
                    //   @Override
                    //  public void onClick(View view) {
                    //   Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    //  .setAction("Action", null).show();
                    // }
                    // });
                    Button power_btn = findViewById(R.id.button_power_center);
                    Button btn_front = findViewById(R.id.button_front);
                    Button btn_back = findViewById(R.id.button_back);
                    Button btn_left = findViewById(R.id.button_left);
                    Button btn_right = findViewById(R.id.button_right);

                    Button button_huishou = findViewById(R.id.button_huishou);
                    Button button_jingli = findViewById(R.id.button_jingli);
                    Button button_woshou = findViewById(R.id.button_woshou);
                    Button button_jushou = findViewById(R.id.button_jushou);

                    Button button_jiewu = findViewById(R.id.button_jiewu);
                    Button button_balei = findViewById(R.id.button_balei);
                    Button button_jixiewu = findViewById(R.id.button_jixiewu);
                    Button button_disike = findViewById(R.id.button_disike);

                    Button btn_exit = findViewById(R.id.button_p_exit);
                    btn_exit.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            new AlertDialog.Builder(MainActivity.this)
                                    .setIcon(android.R.drawable.ic_dialog_info)
                                    .setTitle("退出提示")
                                    .setMessage("确定要退出应用吗?") // 提示信息
                                    .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                                        @Override
                                        public void onClick(DialogInterface dialog, int which) {
                                            // 用户点击确定,执行退出逻辑
                                            if(power_counter % 2 == 0)
                                            {
                                                mTransmit.stop();
                                            }

                                            finish();
                                            android.os.Process.killProcess(android.os.Process.myPid());
                                            System.exit(0);
                                        }
                                    })
                                    .setNegativeButton("取消", null) // 用户点击取消,不做任何事
                                    .show();
                        }
                    });

                    BtnEnable(false);
                    power_btn.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {

                            if (vibrator != null && vibrator.hasVibrator()) {
                                // Android 8.0 (API 26) 及以上版本
                                if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
                                    VibrationEffect effect = VibrationEffect.createOneShot(
                                            50, // 震动时长(毫秒)
                                            VibrationEffect.DEFAULT_AMPLITUDE // 使用默认震动强度
                                    );
                                    vibrator.vibrate(effect);
                                } else {
                                    // 旧版本 API
                                    vibrator.vibrate(50);
                                }
                            }
                            //  Toast toast= Toast.makeText(MainActivity.this, "您点击了启动按钮",Toast.LENGTH_SHORT);
                            //  toast.show();
                            EditText remote_ip = findViewById(R.id.editText_ip);
                            EditText remote_port = findViewById(R.id.editText_port);
                            String remote_ip2 = remote_ip.getText().toString();
                            int remote_port2 = Integer.parseInt(remote_port.getText().toString());
                            if(power_counter % 2 == 1)
                            {
                                power_counter++;
                                BtnEnable(true);
                                //new CheckThread(remote_ip2).start(); //ping功能
                            }
                            else
                            {
                                power_counter++;
                                BtnEnable(false);
                                mTransmit.stop();
                                ShowMsg("断开连接。。。");
                                return;

                            }
                            ShowMsg("开始连接。。。");
                            mTransmit = new MessageTransmit(remote_ip2,remote_port2);//创建一个消息传输
                            new Thread(mTransmit).start();//启动消息传输线程

                         //


                           // Intent intent = new Intent(MainActivity.this, SocketActivity.class);
                          //  startActivity(intent);


                        }
                    });
                    btn_front.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            Toast toast= Toast.makeText(MainActivity.this, "执行向前移动",Toast.LENGTH_SHORT);
                            toast.show();
                            vibration();
                            Message msg = Message.obtain();
                            msg.obj = msg_front;//et_socket.getText().toString();//消息内容
                            // 通过消息线程的发送处理器,向后端发送消息
                            mTransmit.mSendHandler.sendMessage(msg);
                        }
                    });
                    btn_back.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            Toast toast= Toast.makeText(MainActivity.this, "执行向后移动",Toast.LENGTH_SHORT);
                            toast.show();
                            vibration();
                            Message msg = Message.obtain();
                            msg.obj = msg_back;//et_socket.getText().toString();//消息内容
                            // 通过消息线程的发送处理器,向后端发送消息
                            mTransmit.mSendHandler.sendMessage(msg);
                        }
                    });
                    btn_left.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            Toast toast= Toast.makeText(MainActivity.this, "执行向左移动",Toast.LENGTH_SHORT);
                            toast.show();
                            vibration();
                            Message msg = Message.obtain();
                            msg.obj = msg_left;//et_socket.getText().toString();//消息内容
                            // 通过消息线程的发送处理器,向后端发送消息
                            mTransmit.mSendHandler.sendMessage(msg);
                        }
                    });
                    btn_right.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            Toast toast= Toast.makeText(MainActivity.this, "执行向右移动",Toast.LENGTH_SHORT);
                            toast.show();
                            vibration();
                            Message msg = Message.obtain();
                            msg.obj = msg_right;//et_socket.getText().toString();//消息内容
                            // 通过消息线程的发送处理器,向后端发送消息
                            mTransmit.mSendHandler.sendMessage(msg);
                        }
                    });

                    button_huishou.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                           // Toast toast= Toast.makeText(MainActivity.this, "执行向右移动",Toast.LENGTH_SHORT);
                           // toast.show();
                            vibration();
                            Message msg = Message.obtain();
                            msg.obj = rbt_huishou;//et_socket.getText().toString();//消息内容
                            // 通过消息线程的发送处理器,向后端发送消息
                            mTransmit.mSendHandler.sendMessage(msg);
                        }
                    });
                    button_jingli.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            //Toast toast= Toast.makeText(MainActivity.this, "执行向右移动",Toast.LENGTH_SHORT);
                           // toast.show();
                            vibration();
                            Message msg = Message.obtain();
                            msg.obj = rbt_jingli;//et_socket.getText().toString();//消息内容
                            // 通过消息线程的发送处理器,向后端发送消息
                            mTransmit.mSendHandler.sendMessage(msg);
                        }
                    });
                    button_woshou.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                           // Toast toast= Toast.makeText(MainActivity.this, "执行向右移动",Toast.LENGTH_SHORT);
                           // toast.show();
                            vibration();
                            Message msg = Message.obtain();
                            msg.obj = rbt_woshou;//et_socket.getText().toString();//消息内容
                            // 通过消息线程的发送处理器,向后端发送消息
                            mTransmit.mSendHandler.sendMessage(msg);
                        }
                    });
                    button_jushou.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                           // Toast toast= Toast.makeText(MainActivity.this, "执行向右移动",Toast.LENGTH_SHORT);
                           // toast.show();
                            vibration();
                            Message msg = Message.obtain();
                            msg.obj = rbt_jushou;//et_socket.getText().toString();//消息内容
                            // 通过消息线程的发送处理器,向后端发送消息
                            mTransmit.mSendHandler.sendMessage(msg);
                        }
                    });

                    //
                    button_jiewu.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            // Toast toast= Toast.makeText(MainActivity.this, "执行向右移动",Toast.LENGTH_SHORT);
                            // toast.show();
                            vibration();
                            Message msg = Message.obtain();
                            msg.obj = rbt_jiewu;//et_socket.getText().toString();//消息内容
                            // 通过消息线程的发送处理器,向后端发送消息
                            mTransmit.mSendHandler.sendMessage(msg);
                        }
                    });
                    button_balei.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            // Toast toast= Toast.makeText(MainActivity.this, "执行向右移动",Toast.LENGTH_SHORT);
                            // toast.show();
                            vibration();
                            Message msg = Message.obtain();
                            msg.obj = rbt_balei;//et_socket.getText().toString();//消息内容
                            // 通过消息线程的发送处理器,向后端发送消息
                            mTransmit.mSendHandler.sendMessage(msg);
                        }
                    });
                    button_jixiewu.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            // Toast toast= Toast.makeText(MainActivity.this, "执行向右移动",Toast.LENGTH_SHORT);
                            // toast.show();
                            vibration();
                            Message msg = Message.obtain();
                            msg.obj = rbt_jixiewu;//et_socket.getText().toString();//消息内容
                            // 通过消息线程的发送处理器,向后端发送消息
                            mTransmit.mSendHandler.sendMessage(msg);
                        }
                    });
                    button_disike.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            // Toast toast= Toast.makeText(MainActivity.this, "执行向右移动",Toast.LENGTH_SHORT);
                            // toast.show();
                            vibration();
                            Message msg = Message.obtain();
                            msg.obj = rbt_disike;//et_socket.getText().toString();//消息内容
                            // 通过消息线程的发送处理器,向后端发送消息
                            mTransmit.mSendHandler.sendMessage(msg);
                        }
                    });


                }
                private class CheckThread extends Thread{
                    private String mHostName;
                    public CheckThread(String host_name){
                        mHostName = host_name;
                    }
                    public void run() {//获得一个默认的消息对象
                        Message message = Message.obtain();
                        try {//根据主机名称获得主机名称对象
                            InetAddress host = InetAddress.getByName(mHostName);
                            //检查该主机在规定时间内能否连上
                            boolean isReachable = host.isReachable(5000);
                            String desc = (isReachable) ? "可以连接" : "无法连接-检查远程主机防火墙是否关闭";
                            if (isReachable) {//可以连接
                                desc = String.format("%s\n主机名为%s\n主机地址为%s",
                                        desc, host.getHostName(), host.getHostAddress());
                            }
                            message.what = 0;
                            message.obj = desc;
                        } catch (Exception e) {
                            e.printStackTrace();
                            message.what = -1;
                            message.obj = e.getMessage();
                        }
                        //向接收处理器发送检查结果消息
                        mHandler.sendMessage(message);
                    }
                }
                //创建一个检查结果的接收处理器
                private Handler mHandler = new Handler()
                {//在收到结果消息时触发
                    public void handleMessage(Message msg)
                    {
                        // tv_host_name.setText("主机检查结果如下:\n" + msg.obj);
                        Log.d("info1","主机检查结果如下:\n" + msg.obj);
                        Toast toast= Toast.makeText(MainActivity.this, "主机检查结果如下:\n" + msg.obj,Toast.LENGTH_SHORT);
                        toast.show();
                    }
                };
                public void vibration()
                {
                    if (vibrator != null && vibrator.hasVibrator()) {
                        // Android 8.0 (API 26) 及以上版本
                        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
                            VibrationEffect effect = VibrationEffect.createOneShot(
                                    50, // 震动时长(毫秒)
                                    VibrationEffect.DEFAULT_AMPLITUDE // 使用默认震动强度
                            );
                            vibrator.vibrate(effect);
                        } else {
                            // 旧版本 API
                            vibrator.vibrate(50);
                        }
                    }
                }
                public void ShowMsg(String msg)
                {
                    Toast toast= Toast.makeText(MainActivity.this,msg,Toast.LENGTH_SHORT);
                    toast.show();
                }
                public void BtnEnable(boolean value)
                {
                    Button btn_front = findViewById(R.id.button_front);
                    Button btn_back = findViewById(R.id.button_back);
                    Button btn_left = findViewById(R.id.button_left);
                    Button btn_right = findViewById(R.id.button_right);

                    Button btn_arm1 = findViewById(R.id.button_huishou);
                    Button btn_arm2 = findViewById(R.id.button_jingli);
                    Button btn_arm3 = findViewById(R.id.button_woshou);
                    Button btn_arm4 = findViewById(R.id.button_jushou);

                    Button btn_dance1 = findViewById(R.id.button_jiewu);
                    Button btn_dance2 = findViewById(R.id.button_balei);
                    Button btn_dance3 = findViewById(R.id.button_jixiewu);
                    Button btn_dance4 = findViewById(R.id.button_disike);

                    btn_front.setEnabled(value);
                    btn_back.setEnabled(value);
                    btn_left.setEnabled(value);
                    btn_right.setEnabled(value);

                    btn_arm1.setEnabled(value);
                    btn_arm2.setEnabled(value);
                    btn_arm3.setEnabled(value);
                    btn_arm4.setEnabled(value);

                    btn_dance1.setEnabled(value);
                    btn_dance2.setEnabled(value);
                    btn_dance3.setEnabled(value);
                    btn_dance4.setEnabled(value);

                }
                @Override
                public boolean onCreateOptionsMenu(Menu menu) {
                    // Inflate the menu; this adds items to the action bar if it is present.
                    getMenuInflater().inflate(R.menu.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();

                    //noinspection SimplifiableIfStatement
                    if (id == R.id.action_settings) {
                        return true;
                    }

                    return super.onOptionsItemSelected(item);
                }
            }
package com.example.myapplication;

import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.os.Message;
import android.util.Log;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.net.Socket;

public class MessageTransmit implements Runnable {//以下为Socket服务器的Ip和端口,根据实际情况修改
    // --- 新增:声明用于存储参数的成员变量 ---
    private String mUserParamIP;
    private int mUserParamPort;
    // 1. 创建一个 HandlerThread
    private HandlerThread mSendThread;
    // 2. 声明一个与该线程关联的 Handler
    public Handler mSendHandler; //--new
    // --- 新增:自定义构造函数,用于接收外部传入的参数 ---
    public MessageTransmit(String userString, int userInt) {
        this.mUserParamIP = userString;
        this.mUserParamPort = userInt;

        // 3. 初始化 HandlerThread,并给它起个名字
        mSendThread = new HandlerThread("MessageTransmitThread");
        // 4. 启动线程,线程启动后会自动创建 Looper
        mSendThread.start();

        // 5. 关键步骤:使用 mSendThread 的 Looper 来创建 Handler
        // 这样,handleMessage 方法就会在 "MessageTransmitThread" 这个后台线程中执行
        mSendHandler = new Handler(mSendThread.getLooper()) {
            @Override
            public void handleMessage(Message msg) {
                String send_msg = msg.obj.toString() + "\n";
                try {
                    // 网络写入操作,现在安全地在后台线程执行
                    if (mWriter != null) {
                        mWriter.write(send_msg.getBytes("utf8"));
                        mWriter.flush(); // 通常写入后需要 flush
                    }
                } catch (Exception e) {
                    Log.e("info_tt:", "异常信息", e);
                    e.printStackTrace();
                }
            }
        };


}
   // private static final String SOCKET_IP = "192.168.10.102";
   // private static final int SOCKET_PORT = 32100;
    private BufferedReader mReader = null;//声明一个缓存读取器对象
    private OutputStream mWriter = null;//声明一个输出流对象
    Socket socket = new Socket();
    @Override
    public void run() {//创建一个套接字对象

        try {
            //命令套接字连接指定地址的指定端口

            socket.connect(new InetSocketAddress(mUserParamIP, mUserParamPort), 3000);
            //根据套接字的输入流,构建缓存读取器
            mReader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
            //获得套接字的输出流
            mWriter = socket.getOutputStream();
            //启动一条子线程来读取服务器的返回数据
            new RecvThread().start();
            //为当前线程初始化消息队列
            Looper.prepare();//让线程的消息队列开始运行,之后就可以接收消息了
            Looper.loop();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    //创建一个发送处理器对象,让App向后台服务器发送消息
//    public Handler mSendHandler = new Handler() {
//        //在收到消息时触发
//        public void handleMessage(Message msg) {
//            //换行符相当于回车键,表示我写好了发出去吧
//            String send_msg = msg.obj.toString() + "\n";
//            try {
//                //往输出流对象中写入数据
//                mWriter.write(send_msg.getBytes("utf8"));
//            } catch (Exception e) {
//                Log.e("info_tt:","异常信息",e);
//                e.printStackTrace();
//            }
//        }
//    };
    // 提供一个方法来安全地停止线程
    public void stop() {
        if (mSendThread != null) {
            mSendThread.quitSafely();
            // 假设 socket 是一个已建立的 Socket 对象
            try {
                // 1. 调用 shutdown 以确保数据发送完毕
                socket.shutdownOutput(); // 或者 socket.shutdownInput(),或两者都调用
            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                try {
                    // 2. 在 finally 块中确保 close() 被调用
                    socket.close();

                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
    //定义消息接收子线程,让App从后台服务器接收消息
    private class RecvThread extends Thread {
        @Override
        public void run() {
            try {
                String content;//读取到来自服务器的数据
                while ((content = mReader.readLine()) != null) {//获得一个默认的消息对象
                    Message msg = Message.obtain();
                    msg.obj = content;//消息描述/
                    // 通知SocketActivity收到消息
                    SocketActivity.mHandler.sendMessage(msg);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

}
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <com.google.android.material.appbar.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay"/>

    <LinearLayout
        android:id="@+id/linear_main"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal">

        <LinearLayout
            android:id="@+id/linear1"
            android:layout_width="288dp"
            android:layout_height="match_parent"
            android:background="@drawable/bg2"
            android:orientation="vertical">

            <LinearLayout
                android:id="@+id/linear3"
                android:layout_width="match_parent"
                android:layout_height="20dp"
                android:background="@color/design_default_color_primary_dark"
                android:orientation="horizontal">

                <TextView
                    android:id="@+id/textView"
                    android:layout_width="1dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:background="@drawable/bg_capsule_btn2"
                    android:text="Nexus"
                    android:textSize="8dp" />

                <Space
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1" />

                <TextView
                    android:id="@+id/textView2"
                    android:layout_width="1dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:background="@drawable/bg_capsule_btn2"
                    android:text="WIFI"
                    android:textSize="8dp" />

            </LinearLayout>

            <ImageView
                android:id="@+id/imageView"
                android:layout_width="match_parent"
                android:layout_height="270dp"
                app:srcCompat="@drawable/robot1" />

            <LinearLayout
                android:id="@+id/linear_ip"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">

                <TextView
                    android:id="@+id/textView_ip"
                    android:layout_width="10dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:text="IP:"
                    android:textColor="#FFFFFF"
                    android:textSize="10sp" />

                <EditText
                    android:id="@+id/editText_ip"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:ems="10"
                    android:inputType="textPersonName"
                    android:text="192.168.10.102"
                    android:textColor="@android:color/background_light"
                    android:textSize="10sp" />
            </LinearLayout>

            <LinearLayout
                android:id="@+id/linear_port"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:textColor="#FFFFFF">

                <TextView
                    android:id="@+id/textView_port"
                    android:layout_width="10dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:text="端口:"
                    android:textColor="@android:color/background_light"
                    android:textSize="10sp" />

                <EditText
                    android:id="@+id/editText_port"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:ems="10"
                    android:inputType="textPersonName"
                    android:text="32100"
                    android:textColor="@android:color/background_light"
                    android:textSize="10sp" />

                <Button
                    android:id="@+id/button_p_exit"
                    android:layout_width="20dp"
                    android:layout_height="30dp"
                    android:layout_weight="1"
                    android:background="@drawable/left" />
            </LinearLayout>

        </LinearLayout>

        <LinearLayout
            android:id="@+id/linear2"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@drawable/bg1"
            android:orientation="vertical">

            <androidx.appcompat.widget.Toolbar
                android:id="@+id/toolbar2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:minHeight="?attr/actionBarSize"
                android:theme="?attr/actionBarTheme">

                <RelativeLayout
                    android:id="@+id/relative1"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">

                    <com.google.android.material.tabs.TabLayout
                        android:id="@+id/tablay1"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_centerInParent="true"
                        app:tabGravity="center"
                        app:tabIndicatorHeight="2dp">

                        <com.google.android.material.tabs.TabItem
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="手动操作" />

                        <com.google.android.material.tabs.TabItem
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="智能交互" />

                        <com.google.android.material.tabs.TabItem
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="群集管理" />
                    </com.google.android.material.tabs.TabLayout>
                </RelativeLayout>

            </androidx.appcompat.widget.Toolbar>

            <LinearLayout
                android:id="@+id/linear4"
                android:layout_width="match_parent"
                android:layout_height="210dp"
                android:layout_centerInParent="true"
                android:orientation="vertical">

                <include
                    android:id="@+id/include_custom"
                    layout="@layout/layout_direction_cotrol" />
                >

            </LinearLayout>

            <LinearLayout
                android:id="@+id/linear7"
                android:layout_width="match_parent"
                android:layout_height="130dp"
                android:layout_centerInParent="true"

                android:orientation="horizontal">

                <LinearLayout
                    android:id="@+id/linear5"
                    android:layout_width="200dp"
                    android:layout_height="150dp"
                    android:layout_centerInParent="true"
                    android:orientation="vertical">

                    <include
                        android:id="@+id/include_custom2"
                        layout="@layout/layout_arm_mode" />
                    >
                </LinearLayout>

                <Space
                    android:layout_width="10dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1" />

                <LinearLayout
                    android:id="@+id/linear6"
                    android:layout_width="match_parent"
                    android:layout_height="150dp"
                    android:layout_centerInParent="true"
                    android:layout_marginLeft="5dp"
                    android:orientation="vertical">

                    <include
                        android:id="@+id/include_custom2"
                        layout="@layout/layout_dancing_mode" />
                    >
                </LinearLayout>


            </LinearLayout>



        </LinearLayout>


    </LinearLayout>

</androidx.coordinatorlayout.widget.CoordinatorLayout>

 

posted @ 2026-04-19 22:02  txwtech  阅读(3)  评论(0)    收藏  举报