|
@@ -1,11 +1,15 @@
|
|
|
package com.tencent.liteav.demo.player
|
|
|
|
|
|
+import android.graphics.Typeface.BOLD
|
|
|
+import android.graphics.Typeface.DEFAULT_BOLD
|
|
|
+import android.os.Build
|
|
|
import android.os.Bundle
|
|
|
import android.view.View
|
|
|
import android.view.ViewGroup
|
|
|
import android.view.WindowManager
|
|
|
import android.widget.ImageView
|
|
|
import android.widget.RelativeLayout
|
|
|
+import android.widget.TextView
|
|
|
import androidx.appcompat.app.AppCompatActivity
|
|
|
import androidx.appcompat.content.res.AppCompatResources
|
|
|
import androidx.constraintlayout.widget.ConstraintLayout
|
|
@@ -30,12 +34,14 @@ class PlayerShare : AppCompatActivity() {
|
|
|
|
|
|
private fun createView(): View {
|
|
|
val root = RelativeLayout(shareContext).apply {
|
|
|
+ id = View.generateViewId()
|
|
|
layoutParams = ViewGroup.LayoutParams(
|
|
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
|
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
|
|
)
|
|
|
|
|
|
val subRoot = ConstraintLayout(shareContext).apply {
|
|
|
+ id = View.generateViewId()
|
|
|
layoutParams = RelativeLayout.LayoutParams(
|
|
|
shareContext.resources.getDimension(R.dimen.layour_share_width).toInt(),
|
|
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
|
@@ -49,7 +55,21 @@ class PlayerShare : AppCompatActivity() {
|
|
|
AppCompatResources.getDrawable(shareContext, R.drawable.menu_background)
|
|
|
|
|
|
|
|
|
- backButton = ImageView(shareContext).apply {
|
|
|
+ shareFriend = MenuItemView(shareContext).apply {
|
|
|
+ setTitle("微信")
|
|
|
+ setIcon(R.mipmap.item_favorite)
|
|
|
+ id = View.generateViewId()
|
|
|
+ }
|
|
|
+
|
|
|
+ shareTimeline = MenuItemView(shareContext).apply {
|
|
|
+ setTitle("朋友圈")
|
|
|
+ setIcon(R.mipmap.item_favorited)
|
|
|
+ id = View.generateViewId()
|
|
|
+ }
|
|
|
+
|
|
|
+ backButton = ImageView(shareContext)
|
|
|
+
|
|
|
+ backButton.apply {
|
|
|
setImageResource(R.mipmap.item_back)
|
|
|
|
|
|
id = View.generateViewId()
|
|
@@ -61,11 +81,13 @@ class PlayerShare : AppCompatActivity() {
|
|
|
topToTop = parent.id
|
|
|
bottomToBottom = parent.id
|
|
|
}
|
|
|
+ setOnClickListener {
|
|
|
+ shareContext.finish()
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- shareFriend = MenuItemView(shareContext).apply {
|
|
|
- setTitle("微信")
|
|
|
- setIcon(R.mipmap.item_favorite)
|
|
|
+ val textView = TextView(shareContext).apply {
|
|
|
+ text = "分享"
|
|
|
id = View.generateViewId()
|
|
|
|
|
|
layoutParams = ConstraintLayout.LayoutParams(
|
|
@@ -73,26 +95,45 @@ class PlayerShare : AppCompatActivity() {
|
|
|
ViewGroup.LayoutParams.WRAP_CONTENT,
|
|
|
).apply {
|
|
|
leftToRight = backButton.id
|
|
|
+ rightToRight = parent.id
|
|
|
topToTop = parent.id
|
|
|
+ topMargin = shareContext.resources.getDimension(R.dimen.dp40).toInt()
|
|
|
+ }
|
|
|
+ textSize = 20f
|
|
|
+ typeface = DEFAULT_BOLD
|
|
|
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
|
|
+ lineHeight = shareContext.resources.getDimension(R.dimen.dp28).toInt()
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- shareTimeline = MenuItemView(shareContext).apply {
|
|
|
- setTitle("朋友圈")
|
|
|
- setIcon(R.mipmap.item_favorited)
|
|
|
- id = View.generateViewId()
|
|
|
+ shareFriend.apply {
|
|
|
+ layoutParams = ConstraintLayout.LayoutParams(
|
|
|
+ ViewGroup.LayoutParams.WRAP_CONTENT,
|
|
|
+ ViewGroup.LayoutParams.WRAP_CONTENT,
|
|
|
+ ).apply {
|
|
|
+ leftToRight = backButton.id
|
|
|
+ topToBottom = textView.id
|
|
|
+ rightToLeft = shareTimeline.id
|
|
|
+ topMargin = shareContext.resources.getDimension(R.dimen.dp37).toInt()
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ shareTimeline.apply {
|
|
|
layoutParams = ConstraintLayout.LayoutParams(
|
|
|
ViewGroup.LayoutParams.WRAP_CONTENT,
|
|
|
ViewGroup.LayoutParams.WRAP_CONTENT,
|
|
|
).apply {
|
|
|
leftToRight = shareFriend.id
|
|
|
- topToTop = parent.id
|
|
|
+ topToBottom = textView.id
|
|
|
+ rightToRight = parent.id
|
|
|
+ topMargin = shareContext.resources.getDimension(R.dimen.dp37).toInt()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
addView(backButton)
|
|
|
+ addView(textView)
|
|
|
addView(shareFriend)
|
|
|
addView(shareTimeline)
|
|
|
}
|