Skip to content

Commit 343f3cd

Browse files
shitlimeWhiredPlanck
authored andcommitted
fix: liquid keyboard key_height , margin_x no work
1 parent 7a7997e commit 343f3cd

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

app/src/main/java/com/osfans/trime/ime/symbol/SimpleAdapter.kt

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import android.view.Gravity
99
import android.view.LayoutInflater
1010
import android.view.View
1111
import android.view.ViewGroup
12+
import android.widget.LinearLayout
1213
import android.widget.TextView
1314
import androidx.recyclerview.widget.RecyclerView
1415
import com.osfans.trime.data.theme.ColorManager
@@ -18,7 +19,8 @@ import com.osfans.trime.databinding.SimpleItemOneBinding
1819
import com.osfans.trime.databinding.SimpleItemRowBinding
1920
import splitties.dimensions.dp
2021

21-
class SimpleAdapter(theme: Theme, private val columnSize: Int) : RecyclerView.Adapter<SimpleAdapter.ViewHolder>() {
22+
class SimpleAdapter(theme: Theme, private val columnSize: Int) :
23+
RecyclerView.Adapter<SimpleAdapter.ViewHolder>() {
2224
private val mBeans = mutableListOf<SimpleKeyBean>()
2325
private val mBeansByRows = mutableListOf<List<SimpleKeyBean>>()
2426
val beans get() = mBeans
@@ -42,6 +44,8 @@ class SimpleAdapter(theme: Theme, private val columnSize: Int) : RecyclerView.Ad
4244
}
4345

4446
private val mSingleWidth = theme.liquid.getInt("single_width")
47+
private val mSingleHeight = theme.liquid.getInt("key_height")
48+
private val mStringMarginX = theme.liquid.getFloat("margin_x")
4549
private val mTextSize = theme.generalStyle.labelTextSize
4650
private val mTextColor = ColorManager.getColor("key_text_color")
4751
private val mTypeface = FontManager.getTypeface("key_font")
@@ -57,13 +61,18 @@ class SimpleAdapter(theme: Theme, private val columnSize: Int) : RecyclerView.Ad
5761
parent: ViewGroup,
5862
viewType: Int,
5963
): ViewHolder {
60-
val binding = SimpleItemRowBinding.inflate(LayoutInflater.from(parent.context), parent, false)
61-
val size = parent.dp(mSingleWidth)
64+
val binding =
65+
SimpleItemRowBinding.inflate(LayoutInflater.from(parent.context), parent, false)
66+
val width = parent.dp(mSingleWidth)
67+
val height = parent.dp(mSingleHeight)
68+
val marginX = parent.dp(mStringMarginX).toInt()
6269
val bindings = mutableListOf<SimpleItemOneBinding>()
6370
for (i in 0 until columnSize) {
6471
val sub = SimpleItemOneBinding.inflate(LayoutInflater.from(parent.context), null, false)
6572
bindings.add(sub)
66-
binding.wrapper.addView(sub.root, size, size)
73+
val layoutParams = LinearLayout.LayoutParams(width, height)
74+
layoutParams.setMargins(marginX, 0, marginX, 0)
75+
binding.wrapper.addView(sub.root, layoutParams)
6776
}
6877
val holder = ViewHolder(binding, bindings)
6978

@@ -81,7 +90,8 @@ class SimpleAdapter(theme: Theme, private val columnSize: Int) : RecyclerView.Ad
8190
return holder
8291
}
8392

84-
class ViewHolder(binding: SimpleItemRowBinding, views: List<SimpleItemOneBinding>) : RecyclerView.ViewHolder(binding.root) {
93+
class ViewHolder(binding: SimpleItemRowBinding, views: List<SimpleItemOneBinding>) :
94+
RecyclerView.ViewHolder(binding.root) {
8595
val simpleKeyTexts = views.map { it.root.getChildAt(0) as TextView }
8696
val wrappers = views.map { it.root.apply { getChildAt(1).visibility = View.GONE } }
8797
}

0 commit comments

Comments
 (0)