<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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"
android:background="@drawable/bg_01"
tools:context=".ui.dashboard.DashboardFragment"
android:padding="16dp">
<!-- 屏幕中间的水平分割线 -->
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline_half"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_end="361dp" />
<!-- 垂直中心线(微调为0.47制造不对称科技感) -->
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline_middle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.47" />
<!-- 添加新模型卡片(左上) -->
<com.google.android.material.card.MaterialCardView
android:id="@+id/card_add_model"
android:layout_width="0dp"
android:layout_height="0dp"
app:cardCornerRadius="20dp"
app:cardElevation="8dp"
app:strokeColor="#66FFFFFF"
app:strokeWidth="2dp"
app:cardBackgroundColor="#CCF0F9FF"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/guideline_half"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/guideline_middle"
android:layout_margin="8dp"
android:foreground="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
android:focusable="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:padding="16dp">
<ImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:src="@drawable/baseline_add_24"
android:contentDescription="点击添加新的模型"
app:tint="#2196F3" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="添加新模型"
android:textColor="#1A237E"
android:textSize="16sp"
android:textStyle="bold"
android:letterSpacing="0.02"
android:layout_marginTop="8dp"
android:shadowColor="#66000000"
android:shadowDx="1"
android:shadowDy="1"
android:shadowRadius="2"/>
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
<!-- 查看模型卡片(右上) -->
<com.google.android.material.card.MaterialCardView
android:id="@+id/card_view_model"
android:layout_width="0dp"
android:layout_height="0dp"
app:cardCornerRadius="20dp"
app:cardElevation="8dp"
app:strokeColor="#66FFFFFF"
app:strokeWidth="2dp"
app:cardBackgroundColor="#CCE8F5FF"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/guideline_half"
app:layout_constraintStart_toEndOf="@id/guideline_middle"
app:layout_constraintEnd_toEndOf="parent"
android:layout_margin="8dp"
android:foreground="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
android:focusable="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:padding="16dp">
<ImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:src="@drawable/baseline_list_alt_24"
android:contentDescription="点击查看已添加的模型"
app:tint="#2196F3" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="模型仓库"
android:textColor="#1A237E"
android:textSize="16sp"
android:textStyle="bold"
android:letterSpacing="0.02"
android:layout_marginTop="8dp"
android:shadowColor="#66000000"
android:shadowDx="1"
android:shadowDy="1"
android:shadowRadius="2"/>
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
<!-- 参数编辑卡片(下半) -->
<com.google.android.material.card.MaterialCardView
android:id="@+id/card_edit_model"
android:layout_width="0dp"
android:layout_height="260dp"
app:cardCornerRadius="24dp"
app:cardElevation="12dp"
app:cardBackgroundColor="#DDFFFFFF"
app:strokeColor="#AAE3F2FD"
app:strokeWidth="3dp"
app:layout_constraintTop_toBottomOf="@id/guideline_half"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_margin="8dp"
android:foreground="?attr/selectableItemBackground"
android:clickable="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="24dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="参数控制台"
android:textColor="#0D47A1"
android:textSize="20sp"
android:textStyle="bold"
android:gravity="center"
android:letterSpacing="0.03"
android:fontFamily="sans-serif-condensed"/>
<Space
android:layout_width="match_parent"
android:layout_height="8dp"/>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#330D47A1"
android:layout_marginVertical="8dp"/>
<!-- 这里可以添加参数控制组件 -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="点击选择模型调整参数"
android:textColor="#2196F3"
android:textSize="14sp"
android:gravity="center"
android:layout_marginTop="16dp"/>
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
</androidx.constraintlayout.widget.ConstraintLayout>
package com.di.appforbridge.ui.dashboard;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import com.di.appforbridge.databinding.FragmentModelLibraryBinding;
public class DashboardFragment extends Fragment {
private FragmentModelLibraryBinding binding;
@Override
public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
binding = FragmentModelLibraryBinding.inflate(inflater, container, false);
return binding.getRoot(); // 只返回根视图,不做任何绑定操作
}
@Override
public void onDestroyView() {
super.onDestroyView();
binding = null;
}
}