优化首页背景图和返回按钮虚化问题
@@ -7,7 +7,7 @@ import android.content.pm.PackageManager
|
|||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.graphics.Rect
|
import android.graphics.Rect
|
||||||
import android.graphics.drawable.GradientDrawable
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.util.TypedValue
|
import android.util.TypedValue
|
||||||
@@ -263,12 +263,7 @@ class HomeMenuFragment : Fragment() {
|
|||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
// 为 LinearLayout 设置渐变背景
|
binding.gradientLayout.setBackgroundColor(Color.TRANSPARENT)
|
||||||
setGradientBackground(
|
|
||||||
view = binding.gradientLayout,
|
|
||||||
startColor = resources.getColor(R.color.gradientLayout1),
|
|
||||||
endColor = resources.getColor(R.color.gradientLayout2)
|
|
||||||
)
|
|
||||||
binding.message.setOnClickListener {
|
binding.message.setOnClickListener {
|
||||||
val intent = Intent(requireContext(), MessageActivity::class.java)
|
val intent = Intent(requireContext(), MessageActivity::class.java)
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
@@ -589,17 +584,6 @@ class HomeMenuFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setGradientBackground(
|
|
||||||
view: View,
|
|
||||||
startColor: Int,
|
|
||||||
endColor: Int,
|
|
||||||
orientation: GradientDrawable.Orientation = GradientDrawable.Orientation.TL_BR
|
|
||||||
) {
|
|
||||||
val gradientDrawable = GradientDrawable(orientation, intArrayOf(startColor, endColor))
|
|
||||||
gradientDrawable.gradientType = GradientDrawable.LINEAR_GRADIENT
|
|
||||||
view.background = gradientDrawable
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
binding.rvFamilyList.adapter = null
|
binding.rvFamilyList.adapter = null
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:background="@mipmap/home_back"
|
||||||
tools:context=".home.HomeMenuFragment">
|
tools:context=".home.HomeMenuFragment">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
@@ -140,7 +141,8 @@
|
|||||||
android:layout_marginRight="12dp"
|
android:layout_marginRight="12dp"
|
||||||
android:layout_marginTop="12dp"
|
android:layout_marginTop="12dp"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_weight="1">
|
android:layout_weight="1"
|
||||||
|
android:background="@android:color/transparent">
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/rvDeviceList"
|
android:id="@+id/rvDeviceList"
|
||||||
@@ -152,6 +154,7 @@
|
|||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
android:nestedScrollingEnabled="false"
|
android:nestedScrollingEnabled="false"
|
||||||
android:paddingBottom="16dp"
|
android:paddingBottom="16dp"
|
||||||
|
android:background="@android:color/transparent"
|
||||||
tools:listitem="@layout/item_device" />
|
tools:listitem="@layout/item_device" />
|
||||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 592 B After Width: | Height: | Size: 901 B |
BIN
app/src/main/res/mipmap-xhdpi/home_back.png
Normal file
|
After Width: | Height: | Size: 63 KiB |
|
Before Width: | Height: | Size: 592 B After Width: | Height: | Size: 1.7 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/home_back.png
Normal file
|
After Width: | Height: | Size: 183 KiB |
|
Before Width: | Height: | Size: 592 B After Width: | Height: | Size: 1.3 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/home_back.png
Normal file
|
After Width: | Height: | Size: 296 KiB |