feat: 设置页面ui完成

This commit is contained in:
niushuai233 2022-10-27 16:27:47 +08:00
parent 7d6d9f079a
commit 180aee45c2
4 changed files with 194 additions and 15 deletions

View File

@ -6,13 +6,15 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.ViewModelProvider;
import cc.niushuai.project.devcontrol.base.ui.BaseFragment;
import cc.niushuai.project.devcontrol.databinding.MainNavFragmentSetUpBinding;
public class NavSetUpFragment extends Fragment {
public class NavSetUpFragment extends BaseFragment {
private MainNavFragmentSetUpBinding navFragmentSetUpBinding;
@ -20,18 +22,26 @@ public class NavSetUpFragment extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
navFragmentSetUpBinding = MainNavFragmentSetUpBinding.inflate(inflater, container, false);
navFragmentSetUpBinding = MainNavFragmentSetUpBinding.inflate(getLayoutInflater());
NavSetUpViewModel navSetUpViewModel = new ViewModelProvider(this).get(NavSetUpViewModel.class);
View rootView = navFragmentSetUpBinding.getRoot();
TextView textView = navFragmentSetUpBinding.navSetupFragmentTextview;
navSetUpViewModel.getText().observe(getViewLifecycleOwner(), textView::setText);
this.init();
this.addListener();
rootView.requestLayout();
return rootView;
}
private void addListener() {
}
private void init() {
}
@Override
public void onDestroyView() {
super.onDestroyView();

View File

@ -6,15 +6,123 @@
android:layout_height="match_parent"
tools:context=".ui.nav.setup.NavSetUpFragment">
<TextView
android:id="@+id/nav_setup_fragment_textview"
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/hello_blank_fragment"
android:textAlignment="center"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
android:layout_marginTop="10dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--通用-->
<LinearLayout
android:id="@+id/setup_ll_general"
style="@style/SetupTitleLL">
<TextView
style="@style/SetupTitle"
android:text="@string/setup_general" />
</LinearLayout>
<!--备份-->
<LinearLayout
android:id="@+id/setup_ll_general_backup"
style="@style/SetupTextLL"
android:layout_below="@id/setup_ll_general">
<androidx.appcompat.widget.AppCompatImageView
style="@style/SetupIcon"
app:srcCompat="@drawable/ic_backup" />
<TextView
android:id="@+id/setup_general_backup"
style="@style/SetupText"
android:text="@string/setup_general_backup" />
</LinearLayout>
<!--恢复-->
<LinearLayout
android:id="@+id/setup_ll_general_restore"
style="@style/SetupTextLL"
android:layout_below="@id/setup_ll_general_backup">
<androidx.appcompat.widget.AppCompatImageView
style="@style/SetupIcon"
app:srcCompat="@drawable/ic_restore" />
<TextView
android:id="@+id/setup_general_restore"
style="@style/SetupText"
android:text="@string/setup_general_restore" />
</LinearLayout>
<!--日志-->
<LinearLayout
android:id="@+id/setup_ll_log"
style="@style/SetupTitleLL"
android:layout_below="@id/setup_ll_general_restore">
<TextView
style="@style/SetupTitle"
android:text="@string/setup_log" />
</LinearLayout>
<!--总开关-->
<LinearLayout
android:id="@+id/setup_ll_log_switch"
style="@style/SetupTextLL"
android:layout_below="@id/setup_ll_log">
<androidx.appcompat.widget.AppCompatImageView
style="@style/SetupIcon"
app:srcCompat="@drawable/ic_lock" />
<TextView
android:id="@+id/setup_log_switch"
style="@style/SetupText"
android:text="@string/setup_log_switch" />
</LinearLayout>
<!--总开关-->
<LinearLayout
android:id="@+id/setup_ll_log_level"
style="@style/SetupTextLL"
android:layout_below="@id/setup_ll_log_switch">
<androidx.appcompat.widget.AppCompatImageView
style="@style/SetupIcon"
app:srcCompat="@drawable/ic_level" />
<TextView
android:id="@+id/setup_log_level"
style="@style/SetupText"
android:text="@string/setup_log_level" />
</LinearLayout>
<!--总开关-->
<LinearLayout
android:id="@+id/setup_ll_log_keep_day"
style="@style/SetupTextLL"
android:layout_below="@id/setup_ll_log_level">
<androidx.appcompat.widget.AppCompatImageView
style="@style/SetupIcon"
app:srcCompat="@drawable/ic_log_keep_day" />
<TextView
android:id="@+id/setup_log_keep_day"
style="@style/SetupText"
android:text="@string/setup_log_keep_day" />
</LinearLayout>
</RelativeLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--不可点击的title外层布局-->
<style name="SetupTitleLL">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">25dp</item>
<item name="android:background">@color/main_bg_color</item>
</style>
<!--不可点击的title-->
<style name="SetupTitle">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">match_parent</item>
<item name="android:textSize">12dp</item>
<item name="android:textColor">#FFBB86FC</item>
<item name="android:gravity">center_vertical</item>
</style>
<!--==========================================================================-->
<!--==========================================================================-->
<!--==========================================================================-->
<!--可点击的tv外层布局-->
<style name="SetupTextLL">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">50dp</item>
<item name="android:layout_marginLeft">5dp</item>
<item name="android:layout_marginRight">5dp</item>
<item name="android:orientation">horizontal</item>
</style>
<!--可点击的文本-->
<style name="SetupText">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">match_parent</item>
<item name="android:textSize">16dp</item>.
<item name="android:gravity">center_vertical</item>
<item name="android:layout_marginLeft">5dp</item>
</style>
<!--icon-->
<style name="SetupIcon">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">match_parent</item>
</style>
</resources>

View File

@ -25,6 +25,19 @@
<string name="test_btn_2">btn 2</string>
<string name="test_btn_3">btn 3</string>
<!--测试字符串 end-->
<!--设置页面 start-->
<string name="setup_general">通用</string>
<string name="setup_general_backup">备份</string>
<string name="setup_general_restore">恢复</string>
<string name="setup_log">日志</string>
<string name="setup_log_switch">总开关</string>
<string name="setup_log_level">日志级别</string>
<string name="setup_log_keep_day">保留天数</string>
<!--设置页面 end-->
<!-- 首页 底部导航栏 start-->
<string name="title_bottom_nav_menu_device">设备</string>
<string name="title_bottom_nav_menu_log">日志</string>