Skip to content

Instantly share code, notes, and snippets.

@xloger
Created April 18, 2018 09:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xloger/a67b98a611c4835bae790979443a565e to your computer and use it in GitHub Desktop.
Save xloger/a67b98a611c4835bae790979443a565e to your computer and use it in GitHub Desktop.
class MineFragment : BaseFragment() {
private val mineActionItem = listOf<MineActionItem>(MineActionItem(R.drawable.bill, "账单"),
MineActionItem(R.drawable.member, "中兴会员", "3,765 积分"),
MineActionItem(R.drawable.assets, "总资产", "开启粮食储蓄保障"),
MineActionItem(R.drawable.balance, "余额", "10.00 元"),
MineActionItem(R.drawable.service, "粮食服务"),
MineActionItem(R.drawable.love, "爱心捐赠"))
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
// Inflate the layout for this fragment
return UI {
linearLayout {
backgroundResource = R.color.background
orientation = LinearLayout.VERTICAL
verticalLayout {
for (item in mineActionItem) {
relativeLayout {
backgroundResource = R.drawable.white_bg
isClickable = true
val itemIcon = imageView(item.icon) {
id = Ids.item_mine_icon
}.lparams {
centerVertically()
leftMargin = dimen(R.dimen.w48)
}
val itemName = textView(item.name) {
textSize = 14f
textColorResource = R.color.text
}.lparams {
rightOf(itemIcon)
centerVertically()
leftMargin = dimen(R.dimen.w24)
}
val itemInto = imageView(R.drawable.multiselect){
id = Ids.item_mine_into
}.lparams {
alignParentRight()
centerVertically()
rightMargin = dimen(R.dimen.w30)
}
textView(item.info) {
id = Ids.item_mine_info
textSize = 14f
textColorResource = R.color.text_secondary
}.lparams {
centerVertically()
leftOf(itemInto)
rightMargin = dimen(R.dimen.w40)
}
view {
backgroundResource = R.color.line
}.lparams(width = matchParent, height = dip(1)) {
leftMargin = dimen(R.dimen.w30)
alignParentBottom()
}
}.lparams(height = dimen(R.dimen.h88))
}
}.lparams {
topMargin = dimen(R.dimen.h40)
}
}
}.view
}
private object Ids {
val mine_avatar = 1
val mine_name = 2
val item_mine_icon = 3
val item_mine_info = 4
val item_mine_into = 5
val mine_into = 6
val mine_qrcode: Int = 7
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment