feat: 抽取公共页面

This commit is contained in:
niushuai233 2022-10-19 17:16:19 +08:00
parent df2449c811
commit 044da69a50
4 changed files with 73 additions and 67 deletions

View File

@ -49,11 +49,11 @@ public class PowerSwitchActivity extends BaseActivity {
if (null != data) {
this.device = data;
// 标题名称
TextView titleTextView = findViewById(R.id.power_switch_activity_title_name);
TextView titleTextView = findViewById(R.id.activity_title_name);
titleTextView.setText(device.getName());
// 副标题名称
TextView descTextView = findViewById(R.id.power_switch_activity_title_description);
TextView descTextView = findViewById(R.id.activity_title_description);
descTextView.setText(device.getDescription());
// 开关底部的名称
@ -73,10 +73,12 @@ public class PowerSwitchActivity extends BaseActivity {
binding.powerSwitchActivityContentSwitch.setOnClickListener(this::imageSwitchClickListener);
// 标题栏 返回
binding.powerSwitchActivityTitleBack.setOnClickListener(this::buttonBackClickListener);
findViewById(R.id.activity_title_back).setOnClickListener(this::buttonBackClickListener);
// binding.powerSwitchActivityTitleBack.setOnClickListener(this::buttonBackClickListener);
// 标题栏 更多设置
binding.powerSwitchActivityTitleMoreSet.setOnClickListener(this::buttonMoreSetClickListener);
findViewById(R.id.activity_title_more_set).setOnClickListener(this::buttonMoreSetClickListener);
// binding.powerSwitchActivityTitleMoreSet.setOnClickListener(this::buttonMoreSetClickListener);
}
/**

View File

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@id/activity_layout_title"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/main_bg_color"
android:gravity="center">
<!--标题栏 返回-->
<androidx.appcompat.widget.AppCompatImageButton
android:id="@id/activity_title_back"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:background="@color/empty"
android:scaleType="centerInside"
android:src="@drawable/ic_back_32" />
<!--标题中间部分-->
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="5">
<!--name名称-->
<TextView
android:id="@id/activity_title_name"
android:layout_width="match_parent"
android:layout_height="30dp"
android:gravity="center"
android:text="@string/test_hello_blank_textview_1"
android:textSize="16dp" />
<!--描述信息-->
<TextView
android:id="@id/activity_title_description"
android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_below="@id/activity_title_name"
android:gravity="center"
android:text="@string/test_hello_blank_textview_3"
android:textSize="12dp" />
</RelativeLayout>
<!--标题栏 更多设置-->
<androidx.appcompat.widget.AppCompatImageButton
android:id="@id/activity_title_more_set"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginRight="5dp"
android:layout_weight="1"
android:background="@color/empty"
android:scaleType="centerInside"
android:src="@drawable/ic_more_v_32" />
</LinearLayout>

View File

@ -12,67 +12,14 @@
android:layout_height="match_parent"
android:background="@color/main_bg_color">
<LinearLayout
android:id="@id/power_switch_activity_layout_title"
android:background="@color/main_bg_color"
android:layout_width="match_parent"
android:gravity="center"
android:layout_height="50dp">
<!--标题栏 返回-->
<androidx.appcompat.widget.AppCompatImageButton
android:id="@id/power_switch_activity_title_back"
android:layout_weight="1"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="@color/empty"
android:scaleType="centerInside"
android:src="@drawable/ic_back_32"/>
<!--标题中间部分-->
<RelativeLayout
android:layout_weight="5"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<!--name名称-->
<TextView
android:id="@id/power_switch_activity_title_name"
android:layout_width="match_parent"
android:layout_height="30dp"
android:gravity="center"
android:textSize="16dp"
android:text="@string/test_hello_blank_textview_1"/>
<!--描述信息-->
<TextView
android:id="@id/power_switch_activity_title_description"
android:layout_width="match_parent"
android:layout_height="20dp"
android:gravity="center"
android:textSize="12dp"
android:layout_below="@id/power_switch_activity_title_name"
android:text="@string/test_hello_blank_textview_3"/>
</RelativeLayout>
<!--标题栏 更多设置-->
<androidx.appcompat.widget.AppCompatImageButton
android:id="@id/power_switch_activity_title_more_set"
android:layout_weight="1"
android:layout_width="50dp"
android:layout_height="50dp"
android:scaleType="centerInside"
android:background="@color/empty"
android:src="@drawable/ic_more_v_32"/>
</LinearLayout>
<include layout="@layout/activity_common_title"/>
<RelativeLayout
android:id="@id/power_switch_activity_layout_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/power_switch_activity_layout_title"
android:background="@color/main_bg_color"
>
android:layout_below="@id/activity_layout_title"
android:background="@color/main_bg_color">
<!--中间开关图片 可点击-->
<androidx.appcompat.widget.AppCompatImageView

View File

@ -1,5 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--common start-->
<item name="activity_layout_title" type="id"/>
<item name="activity_title_back" type="id"/>
<item name="activity_title_name" type="id"/>
<item name="activity_title_description" type="id"/>
<item name="activity_title_more_set" type="id"/>
<!--common end-->
<!-- 首页 底部导航栏 start-->
<item name="bottom_nav_device" type="id"/>
<item name="bottom_nav_log" type="id"/>
@ -18,15 +27,8 @@
<!--开关操作页 start-->
<item name="power_switch_activity" type="id"/>
<item name="power_switch_activity_layout" type="id"/>
<item name="power_switch_activity_layout_title" type="id"/>
<item name="power_switch_activity_layout_content" type="id"/>
<!--标题栏-->
<item name="power_switch_activity_title_back" type="id"/>
<item name="power_switch_activity_title_name" type="id"/>
<item name="power_switch_activity_title_description" type="id"/>
<item name="power_switch_activity_title_more_set" type="id"/>
<!--内容栏-->
<item name="power_switch_activity_content_icon" type="id"/>
<item name="power_switch_activity_content_switch" type="id"/>