fengshen
wanghao 5 months ago
parent 4dde09bf41
commit d90dee93cd

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

@ -54,6 +54,6 @@ dependencies {
implementation 'com.tonystark.android:socket:4.1.0'
//使 OkSocketServer Java,Server.
implementation 'com.tonystark.android:socket-server:4.1.0'
implementation 'com.lzy.net:okgo:3.0.4'
}

@ -1,8 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:name=".base.MyApplication"
@ -10,27 +11,36 @@
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/haiwei_logo"
android:label="轮胎"
android:label="轮胎MES"
android:roundIcon="@mipmap/haiwei_logo"
android:supportsRtl="true"
android:theme="@style/Theme.WriteEpc"
android:usesCleartextTraffic="true"
tools:targetApi="31">
<activity
android:name=".SocketActivity"
android:exported="true"
android:theme="@style/socketActivityStyle">
android:name=".ShuangqianActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver
android:name=".broadcast.MyScannerReceiver"
android:enabled="true"
android:exported="true" />
<activity
android:name=".SocketActivity"
android:exported="true"
android:theme="@style/socketActivityStyle"></activity>
<activity
android:name=".KillActivity"
android:exported="true">
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.MAIN" />-->
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
<!-- </intent-filter>-->
<!-- <intent-filter> -->
<!-- <action android:name="android.intent.action.MAIN" /> -->
<!-- <category android:name="android.intent.category.LAUNCHER" /> -->
<!-- </intent-filter> -->
</activity>
<activity
android:name=".MoreActivity"
@ -41,6 +51,14 @@
<!-- <category android:name="android.intent.category.LAUNCHER" /> -->
<!-- </intent-filter> -->
</activity>
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

@ -0,0 +1,187 @@
package com.example.writeepc;
import android.content.IntentFilter;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Toast;
import androidx.databinding.DataBindingUtil;
import com.example.writeepc.base.BaseActivity;
import com.example.writeepc.broadcast.MyScannerCall;
import com.example.writeepc.broadcast.MyScannerReceiver;
import com.example.writeepc.databinding.ActivityShuangqianBinding;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;
import com.lzy.okgo.model.Response;
import com.lzy.okgo.request.base.Request;
import okhttp3.MediaType;
public class ShuangqianActivity extends BaseActivity implements MyScannerCall {
public MediaType mediaType = MediaType.parse("text/xml; charset=utf-8");
private ActivityShuangqianBinding binding;
private MyScannerReceiver myReceiver;
private long exitTime = 0L;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = DataBindingUtil.setContentView(this, R.layout.activity_shuangqian);
initUHFRManager();
initDialog();
myReceiver = new MyScannerReceiver(this);
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("com.rfid.SCAN");
registerReceiver(myReceiver, intentFilter);
}
// 读取
public void readRFID(View view) {
readEPC(12);
}
@Override
protected void readTidReault(boolean readState, String result, byte[] rdata) {
super.readTidReault(readState, result, rdata);
binding.socketEpc.setText(result);
}
// 清空数据
public void clearView(View view) {
binding.socketBarcode.setText(null);
binding.socketEpc.setText(null);
}
// 提交数据
public void submit(View view) {
String epc = binding.socketEpc.getText().toString();
String code = binding.socketBarcode.getText().toString();
if (epc.isEmpty() || code.isEmpty()) return;
callWebService(buildSoapRequest(epc, code));
}
// MES确认
public void mesCormf(View view) {
String epc = binding.socketEpc.getText().toString();
if (epc.isEmpty()) return;
callWebService(buildSelectRequest(epc));
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == 4) {
if ((System.currentTimeMillis() - exitTime) > 2000) {
Toast.makeText(getApplicationContext(), "再按一次退出程序", Toast.LENGTH_SHORT).show();
exitTime = System.currentTimeMillis();
return true;
} else {
finish();
}
}
return false;
}
private void callWebService(String soapRequest) {
// 发送 POST 请求
OkGo.<String>post("http://10.135.55.206:99/WebService.asmx")
.headers("Content-Type", "text/xml; charset=utf-8")
.upString(soapRequest, mediaType)
.execute(new StringCallback() {
@Override
public void onStart(Request<String, ? extends Request> request) {
super.onStart(request);
dialog.show();
}
@Override
public void onSuccess(Response<String> response) {
// 处理响应结果
String result = response.body();
Log.e("TAG", "onSuccess:" + result);
String str = "<faultstring>";
int faultstringIndex = result.indexOf(str);
if (faultstringIndex > -1) {
String faultstring = result.substring(faultstringIndex + str.length(), result.indexOf("</faultstring>"));
tipsDialog.setTip(false, faultstring);
tipsDialog.show();
return;
}
int codeIndex = result.indexOf("<Code>");
if (codeIndex > -1) {
String resultCode = result.substring(codeIndex + 6, result.indexOf("</Code>"));
String resultMsg = result.substring(result.indexOf("<Msg>") + 5, result.indexOf("</Msg>"));
tipsDialog.setTip(resultCode.equals("200"), resultMsg);
tipsDialog.show();
}
}
@Override
public void onError(Response<String> response) {
}
@Override
public void onFinish() {
super.onFinish();
dialog.dismiss();
}
});
}
// 创建提交信息
private String buildSoapRequest(String epcid, String barcode) {
StringBuilder soapRequest = new StringBuilder();
soapRequest.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
soapRequest.append("<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">");
soapRequest.append("<soap:Body>");
soapRequest.append("<RFID_BarcodBind xmlns=\"http://tempuri.org/\">");
soapRequest.append("<epcid>").append(epcid).append("</epcid>");
soapRequest.append("<barcode>").append(barcode).append("</barcode>");
soapRequest.append("</RFID_BarcodBind>");
soapRequest.append("</soap:Body>");
soapRequest.append("</soap:Envelope>");
return soapRequest.toString();
}
// 创建验证信息
private String buildSelectRequest(String epcid) {
StringBuilder soapRequest = new StringBuilder();
soapRequest.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
soapRequest.append("<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">");
soapRequest.append("<soap:Body>");
soapRequest.append("<TyreTracingBack xmlns=\"http://tempuri.org/\">");
soapRequest.append("<epcid>").append(epcid).append("</epcid>");
soapRequest.append("</TyreTracingBack>");
soapRequest.append("</soap:Body>");
soapRequest.append("</soap:Envelope>");
return soapRequest.toString();
}
@Override
public void getScannerData(String data) {
binding.socketBarcode.setText(data);
}
@Override
protected void onDestroy() {
super.onDestroy();
unregisterReceiver(myReceiver);
}
}

@ -1,5 +1,6 @@
package com.example.writeepc;
import android.annotation.SuppressLint;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
@ -12,7 +13,6 @@ import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.Observable;
import androidx.databinding.ObservableArrayList;
import com.example.writeepc.base.BaseActivity;
@ -32,8 +32,8 @@ public class SocketActivity extends BaseActivity {
private ActivitySocketBinding binding;
private View view;
private IConnectionManager manager;
private ObservableArrayList data;
private Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
@ -47,6 +47,10 @@ public class SocketActivity extends BaseActivity {
String errorInfo = msg.getData().getString("data");
Snackbar.make(view, "连接失败,原因是" + errorInfo, Snackbar.LENGTH_LONG).show();
break;
case 3:
break;
}
}
};
@ -76,9 +80,9 @@ public class SocketActivity extends BaseActivity {
startscoket();
}
}
//显示输入弹窗
private void showDialog() {
if (manager!=null && manager.isConnect()){
if (manager != null && manager.isConnect()) {
manager.disconnect();
}
EditText editText = new EditText(this);
@ -95,6 +99,7 @@ public class SocketActivity extends BaseActivity {
}).create().show();
}
// RFID返回结果
@Override
protected void readTidReault(boolean readState, String result, byte[] rdata) {
super.readTidReault(readState, result, rdata);
@ -102,19 +107,20 @@ public class SocketActivity extends BaseActivity {
manager.send(new TestSendData(result));
}
// 连接服务端
private void startscoket() {
String IP = SharedPreferencesUtils.getstring("ip", "");
try {
String[] split = IP.split(":");
ConnectionInfo info = new ConnectionInfo(split[0], Integer.parseInt(split[1]));
manager = OkSocket.open(info);
}catch (ArrayIndexOutOfBoundsException e){
} catch (ArrayIndexOutOfBoundsException e) {
Toast.makeText(this, "IP和端口号异常", Toast.LENGTH_SHORT).show();
showDialog();
return;
}
// 连接回调
manager.registerReceiver(new SocketActionAdapter() {
@Override
public void onSocketConnectionSuccess(ConnectionInfo info, String action) {
@ -129,14 +135,15 @@ public class SocketActivity extends BaseActivity {
super.onSocketReadResponse(info, action, data);
}
// 发送状态
@Override
public void onSocketWriteResponse(ConnectionInfo info, String action, ISendable data) {
Log.e("TAG", "客户端发送数据回调");
super.onSocketWriteResponse(info, action, data);
Snackbar.make(view, "数据发送成功:"+new String(data.parse()), Snackbar.LENGTH_LONG).show();
Snackbar.make(view, "数据发送成功:" + new String(data.parse()), Snackbar.LENGTH_LONG).show();
// Toast.makeText(SocketActivity.this, new String(data.parse()), Toast.LENGTH_SHORT).show();
}
//连接回调
@Override
public void onSocketConnectionFailed(ConnectionInfo info, String action, Exception e) {
super.onSocketConnectionFailed(info, action, e);
@ -152,11 +159,11 @@ public class SocketActivity extends BaseActivity {
handler.sendMessage(msg);
Looper.loop();
}
// 断开事件
@Override
public void onSocketDisconnection(ConnectionInfo info, String action, Exception e) {
super.onSocketDisconnection(info, action, e);
//断开连接
// 断开连接
Snackbar.make(view, "断开服务器连接,等待自动重连中....", Snackbar.LENGTH_LONG).show();
}
@ -164,6 +171,13 @@ public class SocketActivity extends BaseActivity {
manager.connect();
}
@Override
protected void onDestroy() {
super.onDestroy();
manager.disconnect();
handler = null;
}
// 发送实体
public class TestSendData implements ISendable {
private String str = "";
@ -183,11 +197,4 @@ public class SocketActivity extends BaseActivity {
return body;
}
}
@Override
protected void onDestroy() {
super.onDestroy();
manager.disconnect();
handler=null;
}
}

@ -1,13 +1,16 @@
package com.example.writeepc.base;
import android.app.ProgressDialog;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.util.Log;
import android.view.Window;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import com.example.writeepc.dialog.TipsDialog;
import com.handheld.uhfr.UHFRManager;
import com.uhf.api.cls.Reader;
@ -18,16 +21,28 @@ public class BaseActivity extends AppCompatActivity {
public byte[] accesspwd;
public short timeOut = 2000;
public MediaPlayer music;
public ProgressDialog dialog;
public TipsDialog tipsDialog;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
tipsDialog=new TipsDialog(this);
}
public void initDialog() {
dialog = new ProgressDialog(this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setCanceledOnTouchOutside(false);
dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
dialog.setMessage("请求接口中...");
}
public void initUHFRManager() {
uhfrManager = UHFRManager.getInstance();
uhfrManager.setGen2session(false);
uhfrManager.setPower(22,22);
uhfrManager.setPower(30, 30);
accesspwd = Tools.HexString2Bytes("00000000");
music = MediaPlayer.create(this, com.example.writeepc.R.raw.msg);
// int[] power = uhfrManager.getPower();
@ -43,21 +58,22 @@ public class BaseActivity extends AppCompatActivity {
Log.e("TAG", "readTid:" + readerErr.name());
if (readerErr == Reader.READER_ERR.MT_OK_ERR) {
music.start();
readTidReault(true, Tools.Bytes2HexString(rdata, 12),rdata);
readTidReault(true, Tools.Bytes2HexString(rdata, 12), rdata);
} else {
Toast.makeText(this, "读取失败", Toast.LENGTH_SHORT).show();
readTidReault(false, null, null);
}
}
// 1- 读取EPC
// 1- 读取EPC
public void readEPC(int lenth) {
byte[] rdata = new byte[lenth];
Reader.READER_ERR readerErr = uhfrManager.getTagData(1, 2, lenth/2, rdata, accesspwd, timeOut);
Reader.READER_ERR readerErr = uhfrManager.getTagData(1, 2, lenth / 2, rdata, accesspwd, timeOut);
Log.e("TAG", "readTid:" + readerErr.name());
if (readerErr == Reader.READER_ERR.MT_OK_ERR) {
music.start();
readTidReault(true, Tools.Bytes2HexString(rdata, lenth),rdata);
readTidReault(true, Tools.Bytes2HexString(rdata, lenth), rdata);
} else {
Toast.makeText(this, "读取失败", Toast.LENGTH_SHORT).show();
readTidReault(false, null, null);
@ -65,16 +81,16 @@ public class BaseActivity extends AppCompatActivity {
}
protected void readTidReault(boolean readState, String result,byte[] rdata) {
protected void readTidReault(boolean readState, String result, byte[] rdata) {
}
@Override
protected void onDestroy() {
super.onDestroy();
if (uhfrManager!=null){
if (uhfrManager != null) {
uhfrManager.close();
uhfrManager=null;
uhfrManager = null;
}
}

@ -3,6 +3,19 @@ package com.example.writeepc.base;
import android.app.Application;
import com.example.writeepc.utils.SharedPreferencesUtils;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.cache.CacheEntity;
import com.lzy.okgo.cache.CacheMode;
import com.lzy.okgo.cookie.CookieJarImpl;
import com.lzy.okgo.cookie.store.MemoryCookieStore;
import com.lzy.okgo.https.HttpsUtils;
import com.lzy.okgo.interceptor.HttpLoggingInterceptor;
import com.lzy.okgo.model.HttpHeaders;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import okhttp3.OkHttpClient;
/**
@ -19,10 +32,33 @@ public class MyApplication extends Application {
super.onCreate();
application = this;
SharedPreferencesUtils.init(getApplicationContext(), "myapp");
okGoBase();
}
// OKGO 初始化
private void okGoBase() {
HttpHeaders headers = new HttpHeaders();
headers.put("Content-Type", "text/xml; charset=utf-8");
// headers.put("SOAPAction", "http://tempuri.org/RFID_BarcodBind");
OkHttpClient.Builder builder = new OkHttpClient.Builder();
HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor("OkGo");
loggingInterceptor.setPrintLevel(HttpLoggingInterceptor.Level.BODY); // log打印级别决定了log显示的详细程度
loggingInterceptor.setColorLevel(Level.SEVERE); // log颜色级别决定了log在控制台显示的颜色
HttpsUtils.SSLParams sslParams1 = HttpsUtils.getSslSocketFactory(); // 方法一:信任所有证书,不安全有风险
builder.sslSocketFactory(sslParams1.sSLSocketFactory, sslParams1.trustManager);
builder.addInterceptor(loggingInterceptor);
builder.readTimeout(6000, TimeUnit.MILLISECONDS); // 全局的读取超时时间
builder.writeTimeout(6000, TimeUnit.MILLISECONDS); // 全局的写入超时时间
builder.connectTimeout(6000, TimeUnit.MILLISECONDS); // 全局的连接超时时间
builder.cookieJar(new CookieJarImpl(new MemoryCookieStore())); // 使用内存保持cookieapp退出后cookie消失
OkGo.getInstance().init(this).setOkHttpClient(builder.build()) // 建议设置OkHttpClient不设置将使用默认的
.setCacheMode(CacheMode.NO_CACHE) // 全局统一缓存模式,默认不使用缓存,可以不传
.setCacheTime(CacheEntity.CACHE_NEVER_EXPIRE) // 全局统一缓存时间,默认永不过期,可以不传
.setRetryCount(0)
.addCommonHeaders(headers);
}
}

@ -0,0 +1,5 @@
package com.example.writeepc.broadcast;
public interface MyScannerCall {
void getScannerData(String data);
}

@ -0,0 +1,20 @@
package com.example.writeepc.broadcast;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class MyScannerReceiver extends BroadcastReceiver {
private MyScannerCall myScannerCall;
public MyScannerReceiver(MyScannerCall myScannerCall) {
this.myScannerCall = myScannerCall;
}
@Override
public void onReceive(Context context, Intent intent) {
String data = intent.getStringExtra("scannerdata");
myScannerCall.getScannerData(data);
}
}

@ -0,0 +1,63 @@
package com.example.writeepc.dialog;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import com.example.writeepc.R;
/**
* Created by wangh on 2020/10/10-14:57
*/
public class TipsDialog extends Dialog implements View.OnClickListener {
public String tip;
public TextView textView,button;
private ImageView imageView;
private boolean imageState=true;
public TipsDialog(@NonNull Context context) {
super(context, R.style.MyMiddleDialogStyle);
}
public void setTip(String tip) {
this.tip = tip;
}
public void setTip(boolean imageState , String tip) {
this.imageState = imageState;
this.tip = tip;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dialog_tip);
// imageState=false;
imageView=findViewById(R.id.tip_image);
textView=findViewById(R.id.tip_tip);
button=findViewById(R.id.dialog_no);
button.setOnClickListener(this);
}
@Override
public void show() {
super.show();
textView.setText(tip);
if (imageState){
imageView.setImageResource(R.mipmap.chenggong);
}else {
imageView.setImageResource(R.mipmap.icon_jinggao);
}
imageState=false;
}
@Override
public void onClick(View view) {
dismiss();
}
}

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="8dp"/>
<solid android:color="@color/white"/>
</shape>

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<data>
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".ShuangqianActivity">
<TextView
style="@style/info_text"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_gravity="center"
android:background="#6750A4"
android:letterSpacing="0.2"
android:text="MES轮胎绑定"
android:textColor="@color/white"
android:textSize="22sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginTop="20dp"
android:orientation="horizontal">
<TextView
style="@style/info_text"
android:layout_width="110dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:text="扫描条码:" />
<EditText
android:id="@+id/socket_barcode"
style="@style/san_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginTop="20dp"
android:orientation="horizontal">
<TextView
style="@style/info_text"
android:layout_width="110dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:text="扫描RFID:" />
<EditText
android:id="@+id/socket_epc"
style="@style/san_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center" />
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="20dp"
android:layout_weight="1"
android:text="" />
<Button
style="@style/button_style"
android:layout_width="match_parent"
android:layout_height="65dp"
android:onClick="readRFID"
android:text="扫描RFID" />
<Button
style="@style/button_style"
android:layout_width="match_parent"
android:layout_height="65dp"
android:onClick="submit"
android:text="数据提交" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp">
<Button
style="@style/button_style1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="清空" />
<Button
style="@style/button_style1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:onClick="mesCormf"
android:text="MES验证" />
</LinearLayout>
</LinearLayout>
</layout>

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_margin="10dp"
android:layout_height="210dp"
android:background="@drawable/bg_tipdialog"
android:orientation="vertical">
<ImageView
android:id="@+id/tip_image"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="15dp"
android:src="@mipmap/icon_jinggao" />
<TextView
android:id="@+id/tip_tip"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginTop="13dp"
android:gravity="center"
android:text="提示"
android:textColor="@color/black"
android:textSize="18sp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="10dp"
android:background="#e1e1e1" />
<TextView
android:id="@+id/dialog_no"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="我知道了"
android:textColor="@color/blue"
android:textSize="20sp" />
</LinearLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

@ -6,7 +6,7 @@
</style>
<style name="socketActivityStyle" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/blue</item>
<!-- <item name="colorPrimary">?attr/colorPrimaryVariant</item>-->
<item name="colorPrimaryVariant">#E6F2FF</item>
<item name="android:windowLightStatusBar">true</item>
<item name="colorOnPrimary">@color/white</item>
@ -42,5 +42,30 @@
<item name="android:layout_marginEnd">20dp</item>
<item name="android:layout_marginTop">10dp</item>
</style>
<style name="button_style1">
<item name="android:textColor">@color/white</item>
<item name="android:textSize">20sp</item>
<item name="android:gravity">center</item>
<item name="android:letterSpacing">0.2</item>
<item name="android:layout_marginStart">10dp</item>
<item name="android:layout_marginEnd">10dp</item>
</style>
<style name="MyMiddleDialogStyle" parent="@android:style/Theme.Holo.Light.Dialog">
<!-- 窗口背景色 -->
<item name="android:windowBackground">@android:color/transparent</item>
<!--是否有覆盖-->
<item name="android:windowContentOverlay">@null</item>
<!-- 浮于Activity之上 -->
<item name="android:windowIsFloating">true</item>
<!-- 边框 -->
<item name="android:windowFrame">@null</item>
<!-- Dialog以外的区域模糊效果 -->
<item name="android:backgroundDimEnabled">true</item>
<!-- 无标题 -->
<item name="android:windowNoTitle">true</item>
<!-- 半透明 -->
<item name="android:windowIsTranslucent">true</item>
<!--进出动画-->
<item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
</style>
</resources>
Loading…
Cancel
Save