修改游戏专题平铺样式UI

This commit is contained in:
kehaoyuan
2020-06-15 10:34:00 +08:00
parent a579b3fe10
commit 2a03683e1e
11 changed files with 104 additions and 66 deletions

View File

@ -277,7 +277,6 @@ class SubjectAdapter(context: Context,
}
}
} else if (holder is FooterViewHolder) {
holder.initItemPadding()
holder.initFooterViewHolder(mIsLoading, mIsNetworkError, mIsOver, R.string.ask_loadover_hint)
holder.itemView.setOnClickListener {
if (mIsNetworkError) {

View File

@ -68,7 +68,7 @@ class SubjectTileFragment : BaseFragment<Any>() {
if (mSettingsEntity.typeEntity.content.size > 1) {
val adapter = SubjectTypeListAdapter(context!!, mItemClickListener = {
val adapter = SubjectTypeListAdapter(requireContext(), mItemClickListener = {
mSelectedTypeName = it
mSubjectData.filter = UrlFilterUtils.getFilterQuery("type", it)
loadData()

View File

@ -8,9 +8,8 @@ import android.text.TextUtils
import android.view.Gravity
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import android.widget.CheckedTextView
import android.widget.RelativeLayout
import android.widget.TextView
import com.gh.common.util.DisplayUtils
import com.gh.gamecenter.R
import com.lightgame.adapter.BaseRecyclerAdapter
@ -23,15 +22,14 @@ class SubjectTypeListAdapter(context: Context,
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SubjectTypeViewHolder {
val relativeLayout = RelativeLayout(mContext)
relativeLayout.layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, DisplayUtils.dip2px(mContext, 35f))
relativeLayout.layoutParams = ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, DisplayUtils.dip2px(mContext, 32f))
relativeLayout.gravity = Gravity.CENTER
val textView = TextView(mContext)
textView.textSize = 14f
textView.setBackgroundResource(R.drawable.subject_tab_style)
textView.setTextColor(ContextCompat.getColor(mContext, R.color.title))
textView.layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, DisplayUtils.dip2px(mContext, 25f))
val textView = CheckedTextView(mContext)
textView.textSize = 12f
textView.setBackgroundResource(R.drawable.text_blue_or_white_style)
textView.layoutParams = ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, DisplayUtils.dip2px(mContext, 24f))
textView.gravity = Gravity.CENTER
textView.setPadding(DisplayUtils.dip2px(mContext, 10f), 0, DisplayUtils.dip2px(mContext, 10f), 0)
textView.setPadding(DisplayUtils.dip2px(mContext, 8f), 0, DisplayUtils.dip2px(mContext, 8f), 0)
relativeLayout.addView(textView)
return SubjectTypeViewHolder(relativeLayout)
}
@ -41,18 +39,17 @@ class SubjectTypeListAdapter(context: Context,
holder.type.text = mGameType[position]
if (!TextUtils.isEmpty(mCurType) && mCurType == mGameType[position]) {
holder.type.isSelected = true
holder.type.isChecked = true
holder.type.setTextColor(Color.WHITE)
} else {
holder.type.isSelected = false
holder.type.setTextColor(ContextCompat.getColor(mContext, R.color.title))
holder.type.isChecked = false
holder.type.setTextColor(ContextCompat.getColor(mContext, R.color.text_3a3a3a))
}
holder.type.setOnClickListener {
if (holder.adapterPosition == -1) return@setOnClickListener
holder.type.isSelected = true
holder.type.isChecked = true
mCurType = mGameType[holder.adapterPosition]
mItemClickListener.invoke(mGameType[holder.adapterPosition])
notifyDataSetChanged()
@ -63,7 +60,7 @@ class SubjectTypeListAdapter(context: Context,
return mGameType.size
}
inner class SubjectTypeViewHolder(itemView: View) : androidx.recyclerview.widget.RecyclerView.ViewHolder(itemView) {
val type: TextView = (itemView as RelativeLayout).getChildAt(0) as TextView
inner class SubjectTypeViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
val type: CheckedTextView = (itemView as RelativeLayout).getChildAt(0) as CheckedTextView
}
}

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/text_333333" android:state_checked="true" />
<item android:color="@color/text_333333" android:state_pressed="true" />
<item android:color="@color/text_999999" />
</selector>

View File

@ -2,7 +2,6 @@
<selector xmlns:android = "http://schemas.android.com/apk/res/android" >
<item android:drawable = "@drawable/subject_tab_down" android:state_selected = "true" />
<item android:drawable = "@drawable/subject_tab_up" android:state_pressed = "true" />
<item android:drawable = "@android:color/white" android:state_focused = "false" />
</selector >

View 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">
<solid android:color="@color/background" />
<corners android:radius="6dp" />
</shape>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke
android:width="1dp"
android:color="@color/text_dddddd" />
<solid android:color="@color/white" />
<corners android:radius="6dp" />
</shape>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/subject_tiled_tab_select" android:state_pressed="true" />
<item android:drawable="@drawable/subject_tiled_tab_select" android:state_focused="true" />
<item android:drawable="@drawable/subject_tiled_tab_select" android:state_checked="true" />
<item android:drawable="@android:color/transparent" />
</selector>

View File

@ -1,62 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android = "http://schemas.android.com/apk/res/android"
xmlns:app = "http://schemas.android.com/apk/res-auto"
android:layout_width = "match_parent"
android:layout_height = "match_parent"
android:orientation = "vertical" >
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.material.appbar.AppBarLayout
android:id = "@+id/subject_appbar"
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:background = "@android:color/white"
android:gravity = "center"
app:layout_behavior = "com.gh.common.view.FixAppBarLayoutBehavior" >
android:id="@+id/subject_appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:gravity="center"
app:layout_behavior="com.gh.common.view.FixAppBarLayoutBehavior">
<androidx.recyclerview.widget.RecyclerView
android:id = "@+id/subject_type_list"
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
app:layout_scrollFlags = "scroll|enterAlwaysCollapsed" />
android:id="@+id/subject_type_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|enterAlwaysCollapsed" />
<LinearLayout
android:id="@+id/subject_filter_container"
android:layout_width = "246dp"
android:layout_height = "29dp"
android:layout_marginBottom = "20dp"
android:layout_marginTop = "15dp"
android:background = "@drawable/border_black_bg" >
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:layout_marginBottom="16dp"
android:background="@drawable/subject_tiled_tab_background">
<CheckedTextView
android:id = "@+id/subject_tabbar_hottest"
android:layout_width = "123dp"
android:layout_height = "29dp"
android:background = "@drawable/tabbar_left_selector"
android:checked = "true"
android:gravity = "center"
android:text = "最热"
android:textAlignment = "center"
android:textColor = "@color/tabbar_textcolor_selector"
android:textSize = "14sp" />
android:id="@+id/subject_tabbar_hottest"
android:layout_width="wrap_content"
android:layout_height="24dp"
android:background="@drawable/subject_tiled_tab_selector"
android:checked="true"
android:gravity="center"
android:paddingLeft="24dp"
android:paddingRight="24dp"
android:text="最热"
android:textAlignment="center"
android:textColor="@color/subject_tiled_tab_color_selector"
android:textSize="12sp" />
<CheckedTextView
android:id = "@+id/subject_tabbar_newest"
android:layout_width = "123dp"
android:layout_height = "29dp"
android:background = "@drawable/tabbar_right_selector"
android:gravity = "center"
android:text = "最新"
android:textAlignment = "center"
android:textColor = "@color/tabbar_textcolor_selector"
android:textSize = "14sp" />
</LinearLayout >
android:id="@+id/subject_tabbar_newest"
android:layout_width="wrap_content"
android:layout_height="24dp"
android:background="@drawable/subject_tiled_tab_selector"
android:checked="false"
android:gravity="center"
android:paddingLeft="24dp"
android:paddingRight="24dp"
android:text="最新"
android:textAlignment="center"
android:textColor="@color/subject_tiled_tab_color_selector"
android:textSize="12sp" />
</LinearLayout>
</com.google.android.material.appbar.AppBarLayout >
</com.google.android.material.appbar.AppBarLayout>
<FrameLayout
android:id = "@+id/subject_content_rl"
android:layout_width = "match_parent"
android:layout_height = "match_parent"
app:layout_behavior = "@string/appbar_scrolling_view_behavior" />
android:id="@+id/subject_content_rl"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</androidx.coordinatorlayout.widget.CoordinatorLayout >
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -9,5 +9,5 @@
android:paddingRight = "8dp"
android:singleLine="true"
android:background="@drawable/text_blue_or_white_style"
android:textColor = "@drawable/text_black_or_white_color_style"
android:textColor = "@color/text_black_or_white_color_style"
android:textSize = "12sp" />