fix: 修复聊天功能面板左右边距不一致问题
修复聊天功能面板左右边距不一致
This commit is contained in:
parent
c6d6e65f0b
commit
91c24f5b25
@ -16,10 +16,7 @@ class FunctionPanelAdapter(
|
|||||||
private val context: Context
|
private val context: Context
|
||||||
) :
|
) :
|
||||||
BaseAdapter() {
|
BaseAdapter() {
|
||||||
override fun getCount(): Int {
|
override fun getCount(): Int = strings?.size ?: 0
|
||||||
return strings?.size ?: 0
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getItem(position: Int): Any? {
|
override fun getItem(position: Int): Any? {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@ -31,14 +28,18 @@ class FunctionPanelAdapter(
|
|||||||
override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
|
override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
|
||||||
var convertView = convertView
|
var convertView = convertView
|
||||||
val binding: FunctionGridItemBinding
|
val binding: FunctionGridItemBinding
|
||||||
|
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
|
// convertView 为空时,说明需要创建新的视图
|
||||||
binding = FunctionGridItemBinding.inflate(LayoutInflater.from(context), parent, false)
|
binding = FunctionGridItemBinding.inflate(LayoutInflater.from(context), parent, false)
|
||||||
convertView = binding.getRoot()
|
convertView = binding.root
|
||||||
|
// 将 binding 存入 tag,以后可复用
|
||||||
convertView.tag = binding
|
convertView.tag = binding
|
||||||
} else {
|
} else {
|
||||||
|
// convertView 不为空时,直接复用已有的 View
|
||||||
binding = convertView.tag as FunctionGridItemBinding
|
binding = convertView.tag as FunctionGridItemBinding
|
||||||
}
|
}
|
||||||
|
binding.tvItemName.text = strings?.get(position)
|
||||||
|
|
||||||
return convertView
|
return convertView
|
||||||
}
|
}
|
||||||
|
9
app/src/main/res/drawable/bac_chat_function_panel.xml
Normal file
9
app/src/main/res/drawable/bac_chat_function_panel.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
|
||||||
|
<corners android:radius="10dp" />
|
||||||
|
|
||||||
|
<solid android:color="@color/white" />
|
||||||
|
|
||||||
|
</shape>
|
@ -4,6 +4,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="@color/gray"
|
||||||
android:fitsSystemWindows="true"
|
android:fitsSystemWindows="true"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
@ -160,6 +161,7 @@
|
|||||||
android:id="@+id/gv_function_panel"
|
android:id="@+id/gv_function_panel"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="250dp"
|
android:layout_height="250dp"
|
||||||
|
android:background="@color/gray"
|
||||||
android:numColumns="4"
|
android:numColumns="4"
|
||||||
android:visibility="invisible"
|
android:visibility="invisible"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="20dp">
|
android:padding="20dp">
|
||||||
|
|
||||||
@ -9,12 +9,13 @@
|
|||||||
android:id="@+id/iv_item"
|
android:id="@+id/iv_item"
|
||||||
android:layout_width="55dp"
|
android:layout_width="55dp"
|
||||||
android:layout_height="55dp"
|
android:layout_height="55dp"
|
||||||
android:background="@color/black"
|
android:background="@drawable/bac_chat_function_panel"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:id="@+id/tv_item_name"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="5dp"
|
||||||
|
Loading…
Reference in New Issue
Block a user