主窗口添加背景边框。
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Mon Dec 08 06:27:30 GMT 2025
|
||||
#Mon Dec 08 08:09:53 GMT 2025
|
||||
stageCount=3
|
||||
libraryProject=
|
||||
baseVersion=15.12
|
||||
publishVersion=15.12.2
|
||||
buildCount=1
|
||||
buildCount=16
|
||||
baseBetaVersion=15.12.3
|
||||
|
||||
@@ -4,6 +4,8 @@ import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
@@ -19,14 +21,15 @@ import androidx.core.content.ContextCompat;
|
||||
import cc.winboll.studio.libaes.interfaces.IWinBoLLActivity;
|
||||
import cc.winboll.studio.libaes.utils.AESThemeUtil;
|
||||
import cc.winboll.studio.libaes.utils.DevelopUtils;
|
||||
import cc.winboll.studio.libaes.utils.WinBoLLActivityManager;
|
||||
import cc.winboll.studio.libaes.views.ADsBannerView;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.positions.R;
|
||||
import cc.winboll.studio.positions.activities.LocationActivity;
|
||||
import cc.winboll.studio.positions.activities.SettingsActivity;
|
||||
import cc.winboll.studio.positions.activities.WinBoLLActivity;
|
||||
import cc.winboll.studio.positions.utils.AppConfigsUtil;
|
||||
import cc.winboll.studio.positions.utils.ServiceUtil;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
/**
|
||||
* 主页面:仅负责
|
||||
@@ -102,8 +105,22 @@ public class MainActivity extends WinBoLLActivity implements IWinBoLLActivity {
|
||||
|
||||
mADsBannerView = findViewById(R.id.adsbanner);
|
||||
|
||||
setLLMainBackgroundColor();
|
||||
}
|
||||
|
||||
// 在 Activity 的 onCreate() 或需要获取颜色的方法中调用
|
||||
private void setLLMainBackgroundColor() {
|
||||
// 1. 定义要解析的主题属性(这里是 colorAccent)
|
||||
TypedArray a = getTheme().obtainStyledAttributes(new int[]{android.R.attr.colorAccent});
|
||||
// 2. 获取对应的颜色值(默认值可设为你需要的 fallback 颜色,如 Color.GRAY)
|
||||
int colorAccent = a.getColor(0, Color.GRAY);
|
||||
// 3. 必须回收,避免内存泄漏
|
||||
a.recycle();
|
||||
|
||||
LinearLayout llmain = findViewById(R.id.llmain);
|
||||
llmain.setBackgroundColor(colorAccent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
BIN
positions/src/main/res/drawable/activity_background.png
Normal file
BIN
positions/src/main/res/drawable/activity_background.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 MiB |
15
positions/src/main/res/drawable/shape_2px_border.xml
Normal file
15
positions/src/main/res/drawable/shape_2px_border.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle"> <!-- 矩形形状(匹配 LinearLayout ) -->
|
||||
|
||||
<!-- 1px 边框(关键:stroke 标签控制边框) -->
|
||||
<stroke
|
||||
android:width="2px"
|
||||
android:color="?attr/colorAccent" /> <!-- 边框颜色(替换为你的颜色,如 #CCCCCC) -->
|
||||
|
||||
<!-- 可选:设置 LinearLayout 背景色(若需要) -->
|
||||
<solid android:color="#00000000" /> <!-- 内部填充色,默认透明可删除 -->
|
||||
|
||||
<!-- 可选:设置圆角(不需要圆角可删除) -->
|
||||
<corners android:radius="0dp" />
|
||||
</shape>
|
||||
@@ -1,10 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/llmain">
|
||||
|
||||
<cc.winboll.studio.libaes.views.ASupportToolbar
|
||||
android:layout_width="match_parent"
|
||||
@@ -13,33 +13,58 @@
|
||||
android:gravity="center_vertical"/>
|
||||
|
||||
<LinearLayout
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:orientation="vertical"
|
||||
android:background="#00000000"
|
||||
android:layout_weight="1.0">
|
||||
|
||||
<Switch
|
||||
android:id="@+id/switch_service_control"
|
||||
android:layout_margin="16dp"
|
||||
android:text="GPS服务开关"
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/activity_background"
|
||||
android:layout_margin="0dp">
|
||||
|
||||
<Button
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:onClick="onPositions"
|
||||
android:text="位置与任务管理"
|
||||
android:id="@+id/btn_manage_positions"/>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:orientation="vertical"
|
||||
android:layout_weight="1.0">
|
||||
|
||||
<Switch
|
||||
android:id="@+id/switch_service_control"
|
||||
android:text="GPS服务开关"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="120dp"
|
||||
android:layout_marginLeft="50dp"
|
||||
android:layout_marginRight="50dp"
|
||||
android:background="@drawable/shape_2px_border"
|
||||
android:paddingLeft="10dp"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginLeft="50dp"
|
||||
android:layout_marginRight="50dp"
|
||||
android:onClick="onPositions"
|
||||
android:text="位置与任务管理"
|
||||
android:id="@+id/btn_manage_positions"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<cc.winboll.studio.libaes.views.ADsBannerView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/adsbanner"
|
||||
android:layout_alignParentBottom="true"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<cc.winboll.studio.libaes.views.ADsBannerView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/adsbanner"
|
||||
android:layout_alignParentBottom="true"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user