Commit eb96bce6 by 刘鹏

feat: 首页金刚位UI根据设计要求修改文字居中展示

parent 901d7e61
...@@ -3,15 +3,10 @@ package com.yidianling.home.ui.view ...@@ -3,15 +3,10 @@ package com.yidianling.home.ui.view
import android.content.Context import android.content.Context
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.FrameLayout
import android.widget.LinearLayout import android.widget.LinearLayout
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy import com.bumptech.glide.load.engine.DiskCacheStrategy
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 kotlinx.android.synthetic.ydl.home_button_banner_view.view.* import kotlinx.android.synthetic.ydl.home_button_banner_view.view.*
...@@ -28,11 +23,6 @@ class HomeButtonBannerView( ...@@ -28,11 +23,6 @@ class HomeButtonBannerView(
private var homeEvent: IHomeBaseEvent?, private var homeEvent: IHomeBaseEvent?,
var listenFree: Boolean var listenFree: Boolean
) : LinearLayout(mContext) { ) : LinearLayout(mContext) {
private var buttonParams: LinearLayout.LayoutParams? = null
private var buttonParamsFrame: FrameLayout.LayoutParams? = null
private var buttonParamsFrame2: FrameLayout.LayoutParams? = null
init { init {
initView() initView()
} }
...@@ -59,8 +49,6 @@ class HomeButtonBannerView( ...@@ -59,8 +49,6 @@ class HomeButtonBannerView(
.load(R.drawable.qingsu_new_free_dynamic) .load(R.drawable.qingsu_new_free_dynamic)
.diskCacheStrategy(DiskCacheStrategy.RESOURCE) .diskCacheStrategy(DiskCacheStrategy.RESOURCE)
.into(qingsuGif) .into(qingsuGif)
initButtonView()
homeModuleButtonBannerFirst.setOnClickListener { homeModuleButtonBannerFirst.setOnClickListener {
homeEvent?.reservationExpertsClick() homeEvent?.reservationExpertsClick()
} }
...@@ -74,28 +62,4 @@ class HomeButtonBannerView( ...@@ -74,28 +62,4 @@ class HomeButtonBannerView(
homeEvent?.psychologyTestClick() homeEvent?.psychologyTestClick()
} }
} }
/**
* 初始化四个按钮
*/
private fun initButtonView() {
if (null == buttonParams) {
val screenWidth = RxDeviceTool.getScreenWidth(mContext)
// val viewWidth = ((screenWidth - 2 * 9 * RxDeviceTool.getScreenDensity(mContext)) / 4).toInt()
val viewWidth = screenWidth / 4 - 40
val viewHeight = viewWidth
buttonParams = LinearLayout.LayoutParams(viewWidth, viewHeight)
buttonParams!!.setMargins(0, 0, 20, 0)
buttonParamsFrame = FrameLayout.LayoutParams(viewWidth, viewHeight)
buttonParamsFrame2 =
FrameLayout.LayoutParams((viewWidth / 2.0).toInt(), (viewHeight / 2.3).toInt())
// buttonParamsFrame2!!.setMargins((((viewWidth / 20f).toInt())), 0, 0, 0)
qingsuGif.layoutParams = buttonParamsFrame2
homeModuleButtonBannerFirst.layoutParams = buttonParams
homeModuleButtonBannerFourth.layoutParams = buttonParams
homeModuleButtonBannerSecond.layoutParams = buttonParams
homeModuleButtonBannerThird.layoutParams = buttonParams
homeModuleButtonBannerSecondFrame.layoutParams = buttonParamsFrame
}
}
} }
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout 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"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/four_button_constrain" android:id="@+id/four_button_constrain"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
...@@ -9,16 +8,17 @@ ...@@ -9,16 +8,17 @@
android:orientation="horizontal" android:orientation="horizontal"
android:paddingLeft="@dimen/platform_dp_8" android:paddingLeft="@dimen/platform_dp_8"
android:paddingTop="@dimen/platform_dp_8" android:paddingTop="@dimen/platform_dp_8"
> android:paddingRight="8dp">
<RelativeLayout <androidx.constraintlayout.widget.ConstraintLayout
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_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_weight="1" android:layout_weight="1"
android:background="@drawable/home_button_banner_first_img_new" android:background="@drawable/home_button_banner_first_img_new"
android:gravity="center" android:gravity="center">
android:paddingRight="@dimen/platform_dp_8">
<TextView <TextView
android:id="@+id/homeModuleButtonBannerFirstTitle" android:id="@+id/homeModuleButtonBannerFirstTitle"
...@@ -27,25 +27,36 @@ ...@@ -27,25 +27,36 @@
android:text="心理咨询" android:text="心理咨询"
android:textColor="@color/color_1C1F28" android:textColor="@color/color_1C1F28"
android:textSize="15sp" android:textSize="15sp"
android:textStyle="bold" /> android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@id/homeModuleFirstDec"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed" />
<TextView <TextView
android:id="@+id/homeModuleFirstDec"
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:layout_below="@+id/homeModuleButtonBannerFirstTitle"
android:text="3W+师资" android:text="3W+师资"
android:textColor="@color/color_1C1F28" android:textColor="@color/color_1C1F28"
android:textSize="@dimen/platform_sp_12" /> android:textSize="@dimen/platform_sp_12"
</RelativeLayout> app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/homeModuleButtonBannerFirstTitle" />
</androidx.constraintlayout.widget.ConstraintLayout>
<RelativeLayout <androidx.constraintlayout.widget.ConstraintLayout
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_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_weight="1" android:layout_weight="1"
android:background="@drawable/home_confide_free_icon" android:background="@drawable/home_confide_free_icon"
android:gravity="center" android:gravity="center">
android:paddingRight="@dimen/platform_dp_8">
<TextView <TextView
android:id="@+id/homeModuleButtonBannerFourthTitle" android:id="@+id/homeModuleButtonBannerFourthTitle"
...@@ -54,26 +65,36 @@ ...@@ -54,26 +65,36 @@
android:text="心理测试" android:text="心理测试"
android:textColor="@color/color_1C1F28" android:textColor="@color/color_1C1F28"
android:textSize="15sp" android:textSize="15sp"
android:textStyle="bold" /> android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@id/homeModuleButtonBannerFourthdec"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed" />
<TextView <TextView
android:id="@+id/homeModuleButtonBannerFourthdec"
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:textColor="@color/color_1C1F28" android:textColor="@color/color_1C1F28"
android:textSize="@dimen/platform_sp_12" /> android:textSize="@dimen/platform_sp_12"
</RelativeLayout> app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/homeModuleButtonBannerFourthTitle" />
</androidx.constraintlayout.widget.ConstraintLayout>
<RelativeLayout <androidx.constraintlayout.widget.ConstraintLayout
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_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_weight="1" android:layout_weight="1"
android:background="@drawable/home_button_banner_third_img_new" android:background="@drawable/home_button_banner_third_img_new"
android:gravity="center" android:gravity="center"
android:orientation="vertical" android:orientation="vertical">
android:paddingRight="@dimen/platform_dp_8">
<TextView <TextView
android:id="@+id/homeModuleButtonBannerThirdTitle" android:id="@+id/homeModuleButtonBannerThirdTitle"
...@@ -82,30 +103,36 @@ ...@@ -82,30 +103,36 @@
android:text="心理课堂" android:text="心理课堂"
android:textColor="@color/color_1C1F28" android:textColor="@color/color_1C1F28"
android:textSize="15sp" android:textSize="15sp"
android:textStyle="bold" /> android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@id/homeModuleButtonBannerThirdDec"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed" />
<TextView <TextView
android:id="@+id/homeModuleButtonBannerThirdDec"
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:layout_below="@+id/homeModuleButtonBannerThirdTitle"
android:text="学习与成长" android:text="学习与成长"
android:textColor="@color/color_1C1F28" android:textColor="@color/color_1C1F28"
android:textSize="@dimen/platform_sp_12" /> android:textSize="@dimen/platform_sp_12"
</RelativeLayout> app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/homeModuleButtonBannerThirdTitle" />
</androidx.constraintlayout.widget.ConstraintLayout>
<FrameLayout <androidx.constraintlayout.widget.ConstraintLayout
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_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_weight="1" android:layout_weight="1"
android:background="@drawable/home_button_banner_fourth_img_new"> android:background="@drawable/home_button_banner_fourth_img_new">
<RelativeLayout
android:id="@+id/homeModuleButtonBannerSecondFrame"
android:layout_width="78dp"
android:layout_height="78dp"
android:gravity="center"
android:paddingRight="@dimen/platform_dp_8">
<TextView <TextView
android:id="@+id/homeModuleButtonBannerSecondTitle" android:id="@+id/homeModuleButtonBannerSecondTitle"
...@@ -114,21 +141,31 @@ ...@@ -114,21 +141,31 @@
android:text="倾诉热线" android:text="倾诉热线"
android:textColor="@color/color_1C1F28" android:textColor="@color/color_1C1F28"
android:textSize="15sp" android:textSize="15sp"
android:textStyle="bold" /> android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@id/homeModuleButtonBannerSecondDec"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed" />
<TextView <TextView
android:id="@+id/homeModuleButtonBannerSecondDec"
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:text="温暖守护您"
android:textColor="@color/color_1C1F28" android:textColor="@color/color_1C1F28"
android:textSize="@dimen/platform_sp_12" /> android:textSize="@dimen/platform_sp_12"
</RelativeLayout> app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/homeModuleButtonBannerSecondTitle" />
<ImageView <ImageView
android:id="@+id/qingsuGif" android:id="@+id/qingsuGif"
android:layout_width="45dp" android:layout_width="45dp"
android:layout_height="@dimen/platform_dp_22" android:layout_height="@dimen/platform_dp_22"
android:visibility="visible" /> android:visibility="visible"
</FrameLayout> app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout> </LinearLayout>
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