Commit fbf458b1 by ydl

首页改版部分布局修改

parent 4b50b6e0
ext { ext {
kotlin_version = "1.3.21" kotlin_version = "1.3.21"
dev_mode = false dev_mode = true
ydl_app = [ ydl_app = [
appName : "心理咨询壹点灵", appName : "心理咨询壹点灵",
......
...@@ -146,7 +146,6 @@ class YdlHomeAdapter( ...@@ -146,7 +146,6 @@ class YdlHomeAdapter(
//顶部预约专家,即时倾诉,心理课堂,心理测试按钮模块 //顶部预约专家,即时倾诉,心理课堂,心理测试按钮模块
is HomeButtonBannerViewHolder -> { is HomeButtonBannerViewHolder -> {
holder.buttonBannerView.initData( holder.buttonBannerView.initData(
list[position].headerBean?.homeSaleData,
list[position].headerBean?.askCategoryData list[position].headerBean?.askCategoryData
) )
} }
......
...@@ -34,7 +34,8 @@ class HomeArticleView(private val mContext: Context, private var homeEvent: IHom ...@@ -34,7 +34,8 @@ class HomeArticleView(private val mContext: Context, private var homeEvent: IHom
) )
layoutParams = params layoutParams = params
View.inflate(mContext, R.layout.home_article_view, this) View.inflate(mContext, R.layout.home_article_view, this)
homeModuleArticleViewHomeCommonTitleView.setTitle("文章·阅读") homeModuleArticleViewHomeCommonTitleView.setTitle("主题阅读")
homeModuleArticleViewHomeCommonTitleView.setMoreText("更多阅读")
homeModuleArticleViewHomeCommonTitleView.setOnClickListener { homeModuleArticleViewHomeCommonTitleView.setOnClickListener {
homeEvent?.articleMoreClick() homeEvent?.articleMoreClick()
} }
......
...@@ -25,26 +25,6 @@ import kotlinx.android.synthetic.xlzx.home_button_banner_view.view.* ...@@ -25,26 +25,6 @@ import kotlinx.android.synthetic.xlzx.home_button_banner_view.view.*
*/ */
class HomeButtonBannerView(private val mContext: Context, private var homeEvent: IHomeBaseEvent?) : class HomeButtonBannerView(private val mContext: Context, private var homeEvent: IHomeBaseEvent?) :
LinearLayout(mContext) { LinearLayout(mContext) {
/**
* 数据缓存
*/
var mDataList: ArrayList<HomeHeaderBean.AskCategoryDataBean>? = null
/**
* 间隔
*/
var margin: Int = 0
/**
* 是否添加了实时测试状态View
*/
var hasRealTestView: Boolean = false
private var realTestView: HomePagerBannerRealView? = null
/**
* 线
*/
private var lineView: View? = null
private var buttonParams: LinearLayout.LayoutParams? = null
init { init {
initView() initView()
...@@ -58,46 +38,14 @@ class HomeButtonBannerView(private val mContext: Context, private var homeEvent: ...@@ -58,46 +38,14 @@ class HomeButtonBannerView(private val mContext: Context, private var homeEvent:
layoutParams = params layoutParams = params
View.inflate(mContext, R.layout.home_button_banner_view, this) View.inflate(mContext, R.layout.home_button_banner_view, this)
// initButtonView()
val ffrom = PlatformDataManager.getRam().getChannelName()
if (!TextUtils.isEmpty(ffrom) && ffrom.endsWith("huawei")) {
homeModuleButtonBannerThird.visibility = View.GONE
homeModuleButtonBannerSecond.visibility = View.GONE
homeModuleButtonBannerFirst.background =
resources.getDrawable(R.drawable.home_dcotor_bt_bg_huawei)
homeModuleButtonBannerSecond.background =
resources.getDrawable(R.drawable.home_test_bt_bg_hauwei)
homeModuleButtonBannerThird.background =
resources.getDrawable(R.drawable.home_course_bt_bg_huawei)
homeModuleButtonBannerFourth.background =
resources.getDrawable(R.drawable.home_listen_bt_bg_huawei)
homeModuleButtonBannerFirstTitle.setTextColor(Color.WHITE)
tv_first_text.setTextColor(Color.WHITE)
homeModuleButtonBannerFourthTitle.setTextColor(Color.WHITE)
tv_second_text.setTextColor(Color.WHITE)
homeModuleButtonBannerThirdTitle.setTextColor(Color.WHITE)
tv_third_text.setTextColor(Color.WHITE)
homeModuleButtonBannerSecondTitle.setTextColor(Color.WHITE)
tv_fourth_text.setTextColor(Color.WHITE)
homeModuleButtonBannerFirstTitle.textSize = 18f
tv_first_text.textSize = 13f
homeModuleButtonBannerFourthTitle.textSize = 18f
tv_second_text.textSize = 13f
}
homeModuleButtonBannerFirst.setOnClickListener { homeModuleButtonBannerFirst.setOnClickListener {
homeEvent?.reservationExpertsClick() homeEvent?.reservationExpertsClick()
} }
homeModuleButtonBannerSecond.setOnClickListener { homeModuleButtonBannerSecond.setOnClickListener {
homeEvent?.nowConfideClick() homeEvent?.askMoreClick()
} }
homeModuleButtonBannerThird.setOnClickListener { homeModuleButtonBannerThird.setOnClickListener {
homeEvent?.psychologyClassClick() homeEvent?.articleMoreClick()
} }
homeModuleButtonBannerFourth.setOnClickListener { homeModuleButtonBannerFourth.setOnClickListener {
homeEvent?.psychologyTestClick() homeEvent?.psychologyTestClick()
...@@ -106,71 +54,11 @@ class HomeButtonBannerView(private val mContext: Context, private var homeEvent: ...@@ -106,71 +54,11 @@ class HomeButtonBannerView(private val mContext: Context, private var homeEvent:
fun initData( fun initData(
homeSaleData: List<HomeHeaderBean.HomeSaleDataBean>?,
homeCategory: List<HomeHeaderBean.AskCategoryDataBean>? homeCategory: List<HomeHeaderBean.AskCategoryDataBean>?
) { ) {
setRealTextView(homeSaleData) homeEvent?.let { home_category_view.setEvent(it) }
home_category_view.initData(homeCategory)
val ffrom = PlatformDataManager.getRam().getChannelName()
if (!TextUtils.isEmpty(ffrom) && ffrom.endsWith("huawei")) {
home_category_view.visibility = View.GONE
} else {
homeEvent?.let { home_category_view.setEvent(it) }
home_category_view.initData(homeCategory)
}
} }
/**
* 初始化实时测评状态View
*/
private fun initRealTextView() {
if (null == realTestView) {
var realTestParam = FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT
)
realTestView = HomePagerBannerRealView(context, homeEvent!!)
realTestView!!.layoutParams = realTestParam
}
}
private fun initLineView() {
var lineParam =
FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, RxImageTool.dip2px(0.5f))
var dp15 = RxImageTool.dip2px(15f)
lineParam.leftMargin = dp15
lineParam.rightMargin = dp15
lineView = View(context)
lineView!!.setBackgroundColor(resources.getColor(R.color.home_category_view_test_line))
lineView!!.layoutParams = lineParam
}
/**
* 实时测评状态赋值
*/
private fun setRealTextView(list: List<HomeHeaderBean.HomeSaleDataBean>?) {
if (!hasRealTestView) {
initLineView()
ll_home_module_button.addView(lineView)
initRealTextView()
ll_home_module_button.addView(realTestView)
val cutOffParams = FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
RxImageTool.dip2px(0.5f)
)
cutOffParams.height = RxImageTool.dip2px(10f)
val cutOffView = View(context)
cutOffView.setBackgroundColor(resources.getColor(R.color.home_colorBg))
cutOffView.layoutParams = cutOffParams
ll_home_module_button.addView(cutOffView)
hasRealTestView = true
}
realTestView!!.initData(list)
}
} }
\ No newline at end of file
...@@ -30,13 +30,10 @@ class HomeCommonTitleView(private val mContext: Context, private val attributeSe ...@@ -30,13 +30,10 @@ class HomeCommonTitleView(private val mContext: Context, private val attributeSe
fun setTitle(title: String) { fun setTitle(title: String) {
homeModuleCommonTitleViewTitle.text = title homeModuleCommonTitleViewTitle.text = title
}
val isFromXinliZiXunHuawei = fun setMoreText(text: String) {
!TextUtils.isEmpty(ffrom) && ffrom.startsWith("ATK_7") && ffrom.endsWith("huawei") homeModuleCommonTitleViewMorell.visibility = View.VISIBLE
homeModuleCommonTitleViewMoreText.text = text
if (isFromXinliZiXunHuawei) {
view_line.visibility = View.GONE
}
} }
} }
\ No newline at end of file
...@@ -49,7 +49,7 @@ class HomeConfideView(private val mContext: Context, private var homeEvent: Home ...@@ -49,7 +49,7 @@ class HomeConfideView(private val mContext: Context, private var homeEvent: Home
layoutParams = params layoutParams = params
orientation = VERTICAL orientation = VERTICAL
View.inflate(mContext, R.layout.home_confide_view, this) View.inflate(mContext, R.layout.home_confide_view, this)
homeModuleConfideViewHomeCommonTitleView.setTitle("倾诉·排解") homeModuleConfideViewHomeCommonTitleView.setTitle("人生答疑")
homeModuleConfideViewHomeCommonTitleView.setOnClickListener { homeModuleConfideViewHomeCommonTitleView.setOnClickListener {
homeEvent?.confideMoreClick() homeEvent?.confideMoreClick()
} }
......
...@@ -48,7 +48,8 @@ class HomeConsultView(private val mContext: Context, private var homeEvent: IHom ...@@ -48,7 +48,8 @@ class HomeConsultView(private val mContext: Context, private var homeEvent: IHom
layoutParams = params layoutParams = params
orientation = VERTICAL orientation = VERTICAL
View.inflate(mContext, R.layout.home_confide_view, this) View.inflate(mContext, R.layout.home_confide_view, this)
homeModuleConfideViewHomeCommonTitleView.setTitle("咨询·理解") homeModuleConfideViewHomeCommonTitleView.setTitle("心理咨询")
homeModuleConfideViewHomeCommonTitleView.setMoreText("更多咨询")
homeModuleConfideViewHomeCommonTitleView.setOnClickListener { homeModuleConfideViewHomeCommonTitleView.setOnClickListener {
homeEvent?.consultMoreClick() homeEvent?.consultMoreClick()
} }
......
...@@ -33,7 +33,8 @@ class HomeCourseView(private val mContext: Context, private var homeEvent: IHome ...@@ -33,7 +33,8 @@ class HomeCourseView(private val mContext: Context, private var homeEvent: IHome
) )
layoutParams = params layoutParams = params
View.inflate(mContext, R.layout.home_course_view, this) View.inflate(mContext, R.layout.home_course_view, this)
homeModuleCourseViewHomeCommonTitleView.setTitle("学习·成长") homeModuleCourseViewHomeCommonTitleView.setTitle("未知潜能")
homeModuleCourseViewHomeCommonTitleView.setMoreText("更多课程")
homeModuleCourseViewHomeCommonTitleView.setOnClickListener { homeModuleCourseViewHomeCommonTitleView.setOnClickListener {
homeEvent?.courseMreClick() homeEvent?.courseMreClick()
} }
......
...@@ -39,20 +39,9 @@ class HomePagerBannerView(private val mContext: Context, private var homeEvent: ...@@ -39,20 +39,9 @@ class HomePagerBannerView(private val mContext: Context, private var homeEvent:
View.inflate(mContext, R.layout.home_pager_banner_view, this) View.inflate(mContext, R.layout.home_pager_banner_view, this)
initBannerLayout() initBannerLayout()
// val addLayoutParams = RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
// addLayoutParams.setMargins(0, (ScreenUtil.screenWidth * (356f / 750f)).toInt(),0,0)
// homeModulePagerBannerViewAddLayout.layoutParams = addLayoutParams
// if (null == homePagerBannerCategoryView) {
// homePagerBannerCategoryView = HomePagerBannerCategoryView(mContext, homeEvent!!)
// homeModulePagerBannerViewAddLayout.addView(homePagerBannerCategoryView)
// }
} }
private fun initBannerLayout() { private fun initBannerLayout() {
// var screenWidth = RxDeviceTool.getScreenWidth(mContext)
// var viewHeight = screenWidth * 508 / 750
// val params = RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, viewHeight)
// homeModulePagerBannerViewBanner.layoutParams = params
homeModulePagerBannerViewBanner.setIndicatorBottomPadding(50) homeModulePagerBannerViewBanner.setIndicatorBottomPadding(50)
} }
......
...@@ -15,15 +15,14 @@ import kotlinx.android.synthetic.xlzx.home_test_item_view.view.* ...@@ -15,15 +15,14 @@ import kotlinx.android.synthetic.xlzx.home_test_item_view.view.*
/** /**
* @author <a href="https://www.jianshu.com/u/c1e5310dd724">xujian</a> * @author <a href="https://www.jianshu.com/u/c1e5310dd724">xujian</a>
* @描述: 心灵电台模块item * @描述: 测评模块item
* @Copyright Copyright (c) 2019 * @Copyright Copyright (c) 2019
* @Company 壹点灵 * @Company 壹点灵
* @date 2019/02/14 * @date 2019/02/14
*/ */
class HomeTestItemView(private val mContext: Context, private var homeEvent: IHomeBaseEvent?) : class HomeTestItemView(private val mContext: Context, private var homeEvent: IHomeBaseEvent?) :
LinearLayout(mContext) { LinearLayout(mContext) {
private val ffrom = PlatformDataManager.getRam().getChannelName() private var params: LayoutParams? = null
private var params: LinearLayout.LayoutParams? = null
init { init {
initView() initView()
...@@ -31,17 +30,12 @@ class HomeTestItemView(private val mContext: Context, private var homeEvent: IHo ...@@ -31,17 +30,12 @@ class HomeTestItemView(private val mContext: Context, private var homeEvent: IHo
private fun initView() { private fun initView() {
orientation = VERTICAL orientation = VERTICAL
params = LinearLayout.LayoutParams( params = LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT ViewGroup.LayoutParams.WRAP_CONTENT
) )
layoutParams = params layoutParams = params
View.inflate(mContext, R.layout.home_test_item_view, this) View.inflate(mContext, R.layout.home_test_item_view, this)
val isFromXinliZiXunHuawei =
!TextUtils.isEmpty(ffrom) && ffrom.startsWith("ATK_7") && ffrom.endsWith("huawei")
if (isFromXinliZiXunHuawei) {
tv_go.visibility = View.GONE
}
} }
......
package com.yidianling.home.ui.view package com.yidianling.home.ui.view
import android.content.Context import android.content.Context
import android.text.TextUtils
import android.view.View import android.view.View
import android.widget.LinearLayout import android.widget.LinearLayout
import com.ydl.ydl_image.config.ISimpleImageOpConfig
import com.ydl.ydl_image.config.SimpleImageOpConfiger
import com.ydl.ydl_image.manager.YDLImageCacheManager
import com.ydl.ydlcommon.data.PlatformDataManager
import com.yidianling.common.tools.RxDeviceTool
import com.yidianling.common.tools.RxImageTool
import com.yidianling.home.R import com.yidianling.home.R
import com.yidianling.home.event.IHomeBaseEvent import com.yidianling.home.event.IHomeBaseEvent
import com.yidianling.home.model.bean.HomeTestItemBean import com.yidianling.home.model.bean.HomeTestItemBean
...@@ -17,59 +10,29 @@ import kotlinx.android.synthetic.xlzx.home_test_top_item_view.view.* ...@@ -17,59 +10,29 @@ import kotlinx.android.synthetic.xlzx.home_test_top_item_view.view.*
/** /**
* @author <a href="https://www.jianshu.com/u/c1e5310dd724">xujian</a> * @author <a href="https://www.jianshu.com/u/c1e5310dd724">xujian</a>
* @描述: 心灵电台模块item--顶部item * @描述: 测评模块item--顶部item
* @Copyright Copyright (c) 2019 * @Copyright Copyright (c) 2019
* @Company 壹点灵 * @Company 壹点灵
* @date 2019/02/15 * @date 2019/02/15
*/ */
class HomeTestTopItemView(private val mContext: Context, private var homeEvent: IHomeBaseEvent?) : class HomeTestTopItemView(private val mContext: Context, private var homeEvent: IHomeBaseEvent?) :
LinearLayout(mContext) { LinearLayout(mContext) {
private val ffrom = PlatformDataManager.getRam().getChannelName()
init { init {
initView() initView()
} }
private fun initView() { private fun initView() {
orientation = VERTICAL
var screenWidth = RxDeviceTool.getScreenWidth(mContext)
var viewWidth = (screenWidth - 2 * 15 * RxDeviceTool.getScreenDensity(mContext)).toInt()
var viewHeight = viewWidth * 143 / 345
val params = LinearLayout.LayoutParams(viewWidth, viewHeight)
layoutParams = params
View.inflate(mContext, R.layout.home_test_top_item_view, this) View.inflate(mContext, R.layout.home_test_top_item_view, this)
val isFromXinliZiXunHuawei =
!TextUtils.isEmpty(ffrom) && ffrom.startsWith("ATK_7") && ffrom.endsWith("huawei")
if (isFromXinliZiXunHuawei) {
ll_day_test.visibility = View.GONE
}
} }
/** /**
* 刷新数据 * 刷新数据
*/ */
fun updateData(bean: HomeTestItemBean) { fun updateData(bean: HomeTestItemBean) {
var screenWidth = RxDeviceTool.getScreenWidth(mContext)
var viewWidth = (screenWidth - RxImageTool.dip2px(30f))
var viewHeight = viewWidth * 143 / 345
val sp = SimpleImageOpConfiger()
sp.loadingPic = R.drawable.platform_default_img
sp.errorPic = R.drawable.platform_default_img
sp.scaleType = ISimpleImageOpConfig.CENTER_CROP
sp.isCacheOnDisk = true
YDLImageCacheManager.showImage(
mContext,
bean?.shareImage,
homeModuleIntelligentTopViewImage,
viewWidth,
viewHeight,
sp
)
homeModuleIntelligentTopViewTitle.text = bean.name homeModuleTestTopViewTitle.text = bean.name
homeModuleIntelligentTopViewHits.text = bean.testNum.toString() homeModuleTestTopViewHits.text = bean.testNum.toString() + "已测"
this.setOnClickListener { this.setOnClickListener {
homeEvent?.testItemClick(bean.recommendLinkUrl) homeEvent?.testItemClick(bean.recommendLinkUrl)
......
...@@ -30,7 +30,8 @@ class HomeTestView(private val mContext: Context, private var homeEvent: HomeImp ...@@ -30,7 +30,8 @@ class HomeTestView(private val mContext: Context, private var homeEvent: HomeImp
val params = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) val params = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
layoutParams = params layoutParams = params
View.inflate(mContext, R.layout.home_test_view, this) View.inflate(mContext, R.layout.home_test_view, this)
homeModuleIntelligentViewHomeCommonTitleView.setTitle("测试·分析") homeModuleIntelligentViewHomeCommonTitleView.setTitle("测试分析")
homeModuleIntelligentViewHomeCommonTitleView.setMoreText("更多测试")
homeModuleIntelligentViewHomeCommonTitleView.setOnClickListener { homeModuleIntelligentViewHomeCommonTitleView.setOnClickListener {
homeEvent?.testMoreClick() homeEvent?.testMoreClick()
} }
......
...@@ -42,20 +42,10 @@ class HomeModuleCategoryView : FrameLayout { ...@@ -42,20 +42,10 @@ class HomeModuleCategoryView : FrameLayout {
/** /**
* 文本宽度 * 文本宽度
*/ */
var textViewWidth: Int = 0 var imageViewHeight: Int = 0
/**
* 文本高度
*/
var textViewHeight: Int = 0
/**
* 间隔
*/
var margin: Int = 0
var dp8: Int = 0 var dp3: Int = 0
var dp12: Int = 0
private var realTestView: HomePagerBannerRealView? = null
/** /**
* 倍数 * 倍数
*/ */
...@@ -82,11 +72,10 @@ class HomeModuleCategoryView : FrameLayout { ...@@ -82,11 +72,10 @@ class HomeModuleCategoryView : FrameLayout {
*/ */
private fun initView() { private fun initView() {
View.inflate(context, R.layout.home_pager_banner_category_view, this) View.inflate(context, R.layout.home_pager_banner_category_view, this)
val params = FrameLayout.LayoutParams( val params = LayoutParams(
FrameLayout.LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.WRAP_CONTENT LayoutParams.WRAP_CONTENT
) )
// params.topMargin = ScreenUtil.screenHeight * (356f / 750f).toInt()
layoutParams = params layoutParams = params
initArgs() initArgs()
} }
...@@ -95,13 +84,11 @@ class HomeModuleCategoryView : FrameLayout { ...@@ -95,13 +84,11 @@ class HomeModuleCategoryView : FrameLayout {
* 初始化变量 * 初始化变量
*/ */
private fun initArgs() { private fun initArgs() {
categoryWidth = ScreenUtil.screenWidth - RxImageTool.dp2px(30f) categoryWidth = ScreenUtil.screenWidth - RxImageTool.dp2px(12f + 3f + 3f + 12f)
textViewWidth = categoryWidth / 4 imageViewWidth = categoryWidth / 3
imageViewWidth = RxImageTool.dip2px(38f) imageViewHeight = imageViewWidth * 52 / 107
margin = (categoryWidth - 4 * imageViewWidth) / 8 dp3 = RxImageTool.dip2px(3f)
dp8 = RxImageTool.dip2px(8f) dp12 = RxImageTool.dip2px(12f)
//高度=文字12dp+16dp间距
textViewHeight = RxImageTool.dip2px(28f)
} }
fun initData(askCategoryDataBean: List<HomeHeaderBean.AskCategoryDataBean>?) { fun initData(askCategoryDataBean: List<HomeHeaderBean.AskCategoryDataBean>?) {
...@@ -149,23 +136,18 @@ class HomeModuleCategoryView : FrameLayout { ...@@ -149,23 +136,18 @@ class HomeModuleCategoryView : FrameLayout {
homeModulePagerBannerFlRoot.removeAllViews() homeModulePagerBannerFlRoot.removeAllViews()
var i = 0 var i = 0
for (item in mDataList!!) { for (item in mDataList!!) {
if (i > 7) { if (i > 5) {
break break
} }
val imageView = createIcon(i) val imageView = createIcon(i)
val textView = createText(i)
homeModulePagerBannerFlRoot.addView(imageView) homeModulePagerBannerFlRoot.addView(imageView)
homeModulePagerBannerFlRoot.addView(textView)
imageView.setOnClickListener { imageView.setOnClickListener {
homeEvent!!.categoryClick(item) homeEvent!!.categoryClick(item)
} }
textView.setOnClickListener {
homeEvent!!.categoryClick(item)
}
bindIconData(imageView, item) bindIconData(imageView, item)
bindTextData(textView, item)
i++ i++
} }
} }
...@@ -174,21 +156,20 @@ class HomeModuleCategoryView : FrameLayout { ...@@ -174,21 +156,20 @@ class HomeModuleCategoryView : FrameLayout {
* 创建图标 * 创建图标
*/ */
private fun createIcon(i: Int): ImageView { private fun createIcon(i: Int): ImageView {
val imageParams = FrameLayout.LayoutParams(imageViewWidth, imageViewWidth) val imageParams = LayoutParams(imageViewWidth, imageViewHeight)
val imageView = ImageView(context) val imageView = ImageView(context)
imageView.scaleType = ImageView.ScaleType.CENTER_CROP imageView.scaleType = ImageView.ScaleType.CENTER_CROP
if (i > 3) { if (i > 2) {
multiple = 2 //第二行
imageParams.topMargin = imageParams.topMargin = imageViewHeight
imageViewWidth + dp8 + textViewHeight + dp8 + RxImageTool.dip2px(1f) imageParams.leftMargin = dp12 + dp3 * (i - 3) + imageViewWidth * (i - 3)
imageParams.leftMargin = margin * (i - 3) + (i - 4) * (imageViewWidth + margin)
} else { } else {
multiple = 1 //第一行
imageParams.leftMargin = margin * (i + 1) + i * (imageViewWidth + margin) imageParams.topMargin = 0
imageParams.leftMargin = dp12 + dp3 * i + imageViewWidth * i
} }
imageView.layoutParams = imageParams imageView.layoutParams = imageParams
return imageView return imageView
} }
...@@ -199,46 +180,7 @@ class HomeModuleCategoryView : FrameLayout { ...@@ -199,46 +180,7 @@ class HomeModuleCategoryView : FrameLayout {
imageView: ImageView, imageView: ImageView,
categoryBean: HomeHeaderBean.AskCategoryDataBean categoryBean: HomeHeaderBean.AskCategoryDataBean
) { ) {
GlideApp.with(context).load(categoryBean.coverUrl) GlideApp.with(context).load(categoryBean.coverUrl)
.centerCrop().into(imageView) .centerCrop().into(imageView)
} }
/**
* 创建文本
*/
private fun createText(index: Int): TextView {
val textParams = FrameLayout.LayoutParams(textViewWidth, textViewHeight)
val textView = TextView(context)
textView.setTextColor(Color.parseColor("#444444"))
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12f)
textView.gravity = Gravity.CENTER_HORIZONTAL
if (index > 3) {
textParams.topMargin = 2 * (imageViewWidth + dp8) + textViewHeight + dp8
textParams.leftMargin = textViewWidth * (index - 4)
} else {
textParams.topMargin = imageViewWidth + dp8
textParams.leftMargin = textViewWidth * (index)
}
textView.layoutParams = textParams
return textView
}
/**
* 设置文本
*/
private fun bindTextData(textView: TextView, categoryBean: HomeHeaderBean.AskCategoryDataBean) {
textView.text = categoryBean.cateTitle
}
fun onDestory() {
if (null == realTestView) {
return
}
realTestView!!.onDestory()
}
} }
\ No newline at end of file
...@@ -7,6 +7,6 @@ ...@@ -7,6 +7,6 @@
android:width="0.5dp"/> android:width="0.5dp"/>
<corners <corners
android:radius="@dimen/platform_dp_12"/> android:radius="@dimen/platform_dp_14"/>
</shape> </shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/platform_color_FFFFFF"/>
<corners android:radius="14dp"/>
</shape>
\ No newline at end of file
...@@ -2,12 +2,13 @@ ...@@ -2,12 +2,13 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android" <shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"> android:shape="rectangle">
<solid android:color="@color/platform_color_70FFFFFF" /> <gradient
android:startColor="#82A1D4"
android:endColor="#7DACCA"/>
<corners <corners
android:bottomLeftRadius="@dimen/platform_dp_20" android:topRightRadius="@dimen/platform_dp_10"
android:bottomRightRadius="@dimen/platform_dp_20" android:topLeftRadius="@dimen/platform_dp_10"
android:topRightRadius="@dimen/platform_dp_20"
/> />
</shape> </shape>
\ No newline at end of file
...@@ -5,11 +5,6 @@ ...@@ -5,11 +5,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<com.yidianling.home.ui.widget.HomeModuleCategoryView
android:id="@+id/home_category_view"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
...@@ -19,127 +14,103 @@ ...@@ -19,127 +14,103 @@
android:orientation="horizontal" android:orientation="horizontal"
android:paddingBottom="12dp"> android:paddingBottom="12dp">
<LinearLayout
<RelativeLayout
android:id="@+id/homeModuleButtonBannerFirst" android:id="@+id/homeModuleButtonBannerFirst"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="78dp" android:layout_height="78dp"
android:layout_weight="1" android:layout_weight="1"
android:background="@drawable/home_dcotor_bt_bg" android:orientation="vertical"
android:gravity="center_horizontal"> android:gravity="center">
<TextView <ImageView
android:id="@+id/homeModuleButtonBannerFirstTitle" android:layout_width="54dp"
android:layout_width="wrap_content" android:layout_height="38dp"
android:layout_height="wrap_content" android:src="@drawable/home_banner_first_icon"
android:layout_marginTop="7dp" android:scaleType="fitXY"/>
android:text="预约咨询"
android:textColor="@color/platform_black"
android:textSize="@dimen/platform_dp_16"
android:textStyle="bold" />
<TextView <TextView
android:id="@+id/tv_first_text"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@+id/homeModuleButtonBannerFirstTitle" android:text="咨询沟通"
android:text="1W+师资" android:layout_marginTop="7dp"
android:textColor="@color/platform_color_444444" android:textColor="@color/platform_color_242424"
android:textSize="@dimen/platform_dp_11" /> android:textSize="13dp"/>
</RelativeLayout> </LinearLayout>
<RelativeLayout <LinearLayout
android:id="@+id/homeModuleButtonBannerFourth" android:id="@+id/homeModuleButtonBannerFourth"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="78dp" android:layout_height="78dp"
android:layout_marginStart="8dp"
android:layout_weight="1" android:layout_weight="1"
android:background="@drawable/home_listen_bt_bg" android:orientation="vertical"
android:gravity="center_horizontal"> android:gravity="center">
<TextView <ImageView
android:id="@+id/homeModuleButtonBannerFourthTitle" android:layout_width="54dp"
android:layout_width="wrap_content" android:layout_height="38dp"
android:layout_height="wrap_content" android:src="@drawable/home_banner_fourth_icon"
android:layout_marginTop="7dp" android:scaleType="fitXY"/>
android:text="心理测试"
android:textColor="@color/platform_black"
android:textSize="@dimen/platform_dp_16"
android:textStyle="bold" />
<TextView <TextView
android:id="@+id/tv_second_text"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@+id/homeModuleButtonBannerFourthTitle" android:text="心理测试"
android:text="专业权威" android:layout_marginTop="7dp"
android:textColor="@color/platform_color_444444" android:textColor="@color/platform_color_242424"
android:textSize="@dimen/platform_dp_11" /> android:textSize="13dp"/>
</RelativeLayout> </LinearLayout>
<RelativeLayout <LinearLayout
android:id="@+id/homeModuleButtonBannerThird" android:id="@+id/homeModuleButtonBannerThird"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="78dp" android:layout_height="78dp"
android:layout_marginStart="8dp"
android:layout_weight="1" android:layout_weight="1"
android:background="@drawable/home_course_bt_bg" android:orientation="vertical"
android:gravity="center_horizontal" android:gravity="center">
android:orientation="vertical">
<TextView <ImageView
android:id="@+id/homeModuleButtonBannerThirdTitle" android:layout_width="54dp"
android:layout_width="wrap_content" android:layout_height="38dp"
android:layout_height="wrap_content" android:src="@drawable/home_banner_third_icon"
android:layout_marginTop="7dp" android:scaleType="fitXY"/>
android:text="心理课堂"
android:textColor="@color/platform_black"
android:textSize="@dimen/platform_dp_16"
android:textStyle="bold" />
<TextView <TextView
android:id="@+id/tv_third_text"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@+id/homeModuleButtonBannerThirdTitle" android:text="主题阅读"
android:text="学习与成长" android:layout_marginTop="7dp"
android:textColor="@color/platform_color_444444" android:textColor="@color/platform_color_242424"
android:textSize="@dimen/platform_dp_11" /> android:textSize="13dp"/>
</RelativeLayout> </LinearLayout>
<RelativeLayout <LinearLayout
android:id="@+id/homeModuleButtonBannerSecond" android:id="@+id/homeModuleButtonBannerSecond"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="78dp" android:layout_height="78dp"
android:layout_marginStart="8dp"
android:layout_weight="1" android:layout_weight="1"
android:background="@drawable/home_test_bt_bg" android:orientation="vertical"
android:gravity="center_horizontal"> android:gravity="center">
<TextView <ImageView
android:id="@+id/homeModuleButtonBannerSecondTitle" android:layout_width="54dp"
android:layout_width="wrap_content" android:layout_height="38dp"
android:layout_height="wrap_content" android:src="@drawable/home_banner_second_icon"
android:layout_gravity="center" android:scaleType="fitXY"/>
android:layout_marginTop="7dp"
android:text="即时倾诉"
android:textColor="@color/platform_black"
android:textSize="@dimen/platform_dp_16"
android:textStyle="bold" />
<TextView <TextView
android:id="@+id/tv_fourth_text"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@+id/homeModuleButtonBannerSecondTitle" android:text="人生答疑"
android:layout_centerVertical="true" android:layout_marginTop="7dp"
android:text="专业解忧" android:textColor="@color/platform_color_242424"
android:textColor="@color/platform_color_444444" android:textSize="13dp"/>
android:textSize="@dimen/platform_dp_11" /> </LinearLayout>
</RelativeLayout>
</LinearLayout> </LinearLayout>
<com.yidianling.home.ui.widget.HomeModuleCategoryView
android:id="@+id/home_category_view"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout> </LinearLayout>
...@@ -4,56 +4,44 @@ ...@@ -4,56 +4,44 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:paddingTop="@dimen/platform_dp_24" android:paddingTop="@dimen/platform_dp_20"
android:paddingBottom="@dimen/platform_dp_14"> android:paddingBottom="@dimen/platform_dp_6">
<View
android:id="@+id/view_line"
android:layout_width="0dp"
android:layout_height="5dp"
android:background="@drawable/home_common_title_gradient_back"
app:layout_constraintLeft_toLeftOf="@+id/homeModuleCommonTitleViewTitle"
app:layout_constraintRight_toRightOf="@+id/homeModuleCommonTitleViewTitle"
app:layout_constraintBottom_toBottomOf="@+id/homeModuleCommonTitleViewTitle"
android:layout_marginBottom="2dp"/>
<TextView <TextView
android:id="@+id/homeModuleCommonTitleViewTitle" android:id="@+id/homeModuleCommonTitleViewTitle"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingRight="@dimen/platform_dp_1" android:paddingRight="@dimen/platform_dp_1"
tools:text="通用.标题" tools:text="通用标题"
android:textSize="24dp" android:textSize="20dp"
android:textStyle="bold" android:textStyle="bold"
android:textColor="@color/platform_color_333333" android:textColor="@color/platform_color_242424"
android:layout_marginLeft="@dimen/platform_dp_15" android:layout_marginLeft="@dimen/platform_dp_15"
app:layout_constraintLeft_toLeftOf="parent"/> app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent" />
<LinearLayout <LinearLayout
android:layout_width="66dp" android:id="@+id/homeModuleCommonTitleViewMorell"
android:layout_height="@dimen/platform_dp_24" android:layout_width="74dp"
android:layout_height="@dimen/platform_dp_28"
android:orientation="horizontal" android:orientation="horizontal"
android:gravity="center" android:gravity="center"
android:layout_marginBottom="@dimen/platform_dp_3" android:layout_marginBottom="@dimen/platform_dp_3"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
android:layout_marginRight="@dimen/platform_dp_15" android:layout_marginRight="@dimen/platform_dp_15"
android:background="@drawable/home_show_more_line"> android:background="@drawable/home_show_more_line"
android:visibility="gone">
<TextView <TextView
android:id="@+id/homeModuleCommonTitleViewMoreText"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:gravity="center"
android:text="更多" android:text="更多选择"
android:layout_marginLeft="@dimen/platform_dp_2" android:layout_marginLeft="@dimen/platform_dp_2"
android:textColor="@color/platform_color_444444" android:textColor="@color/platform_color_666666"
android:textSize="13sp"/> android:textSize="12dp"/>
<ImageView
android:layout_height="8dp"
android:layout_width="4dp"
android:src="@drawable/home_sale_arrow"
android:layout_marginLeft="3dp"/>
</LinearLayout> </LinearLayout>
......
...@@ -3,109 +3,44 @@ ...@@ -3,109 +3,44 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
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="92dp"
android:background="@drawable/home_test_top_view_layout_back">
<android.support.v7.widget.CardView
android:id="@+id/homeModuleIntelligentTopViewImageCardView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cardCornerRadius="@dimen/platform_dp_7"
app:cardElevation="0dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/homeModuleIntelligentTopViewImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/home_image_default_back"
android:scaleType="centerCrop" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="45" />
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="55"
android:background="@drawable/home_intelligent_gradient_back" />
</LinearLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
<TextView <TextView
android:id="@+id/homeModuleIntelligentTopViewTitle" android:id="@+id/homeModuleTestTopViewTitle"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true" android:layout_marginTop="24dp"
android:layout_marginLeft="@dimen/platform_dp_14" android:layout_marginLeft="@dimen/platform_dp_14"
android:layout_marginRight="@dimen/platform_dp_115" android:layout_marginRight="100dp"
android:layout_marginBottom="@dimen/platform_dp_35"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="1" android:maxLines="1"
android:textColor="@color/platform_color_FFFFFF" android:textColor="@color/platform_color_FFFFFF"
android:textSize="@dimen/platform_dp_24" android:textSize="@dimen/platform_dp_18"
android:textStyle="bold" android:textStyle="bold"
tools:text="先结婚还是先买先结婚还是先买房" /> tools:text="先结婚还是先买先结婚还是先买房" />
<LinearLayout <TextView
android:id="@+id/homeModuleIntelligentTopViewDescLayout" android:id="@+id/homeModuleTestTopViewHits"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="@dimen/platform_dp_18" android:layout_height="wrap_content"
android:layout_alignLeft="@+id/homeModuleIntelligentTopViewTitle" android:layout_marginTop="53dp"
android:layout_alignParentBottom="true" android:layout_marginLeft="16dp"
android:layout_marginBottom="@dimen/platform_dp_14" android:textColor="@color/platform_color_FFFFFF"
android:background="@drawable/home_test_top_view_layout_back" android:textSize="@dimen/platform_dp_12"
android:gravity="center_vertical" tools:text="2486已测" />
android:orientation="horizontal"
android:paddingLeft="@dimen/platform_dp_10"
android:paddingRight="@dimen/platform_dp_10">
<TextView
android:id="@+id/homeModuleIntelligentTopViewHits"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/platform_color_444444"
android:textSize="@dimen/platform_dp_12"
android:textStyle="bold"
tools:text="2486" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="已测"
android:textColor="@color/platform_color_666666"
android:textSize="@dimen/platform_dp_12" />
</LinearLayout>
<RelativeLayout <TextView
android:id="@+id/ll_day_test" android:layout_width="64dp"
android:layout_width="@dimen/platform_dp_64" android:layout_height="28dp"
android:layout_height="@dimen/platform_dp_20" android:text="测试"
android:textColor="#FBAA0E"
android:textSize="13dp"
android:gravity="center"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:background="@drawable/home_intelligent_top_view_recommend_back"> android:layout_marginTop="25dp"
android:layout_marginRight="14dp"
<TextView android:background="@drawable/home_test_top_btn_bg"/>
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="每日一测"
android:textColor="@color/platform_color_242424"
android:textSize="@dimen/platform_dp_12"
android:textStyle="bold" />
</RelativeLayout>
</RelativeLayout> </RelativeLayout>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment