调整礼物栏高度,对文字进行部分对齐

This commit is contained in:
ningwenqiang 2024-10-14 18:23:42 +08:00
parent 9649a7eb01
commit 11ac669077
6 changed files with 97 additions and 8 deletions

View File

@ -153,7 +153,7 @@
android:layout_marginBottom="16dp" android:layout_marginBottom="16dp"
app:layout_constraintBottom_toTopOf="@+id/giftSendBgV" app:layout_constraintBottom_toTopOf="@+id/giftSendBgV"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintDimensionRatio="1.56" app:layout_constraintDimensionRatio="1.5"
app:layout_constraintStart_toStartOf="parent" /> app:layout_constraintStart_toStartOf="parent" />
<View <View

View File

@ -1,13 +1,54 @@
package com.yunbao.live.viewmodel; package com.yunbao.live.viewmodel;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import androidx.lifecycle.ViewModel; import androidx.lifecycle.ViewModel;
import com.yunbao.common.utils.SpUtil; import com.yunbao.common.utils.SpUtil;
import com.yunbao.live.R;
//直播时候位置做的 viewModel 注意这里 //直播时候位置做的 viewModel 注意这里
public class LivePositionViewModel extends ViewModel { public class LivePositionViewModel extends ViewModel {
//值判断到此根节点的位置
private View RootView ;
/**
* 计算控件 Z 相对于 ViewGroupA 的位置
* @param child 当前控件 Z
* @param parent 目标 ViewGroupA
* @return 相对位置 [x, y]
*/
public static int[] calculateRelativePosition(View child, View parent) {
int[] position = new int[2]; // 存储相对位置 [x, y]
child.getLocationInWindow(position);
child.getLocationOnScreen(position);
//child.getLocationInSurface(position);
// while (child != null && child != parent) {
// if (child instanceof ViewGroup) {
// ViewGroup viewGroup = (ViewGroup) child;
// int[] childLocation = new int[2];
// child.getLocationInParent(viewGroup);
// position[0] += childLocation[0];
// position[1] += childLocation[1];
// } else {
// int[] childLocation = new int[2];
// child.getLocationInParent((ViewGroup) child.getParent());
// position[0] += childLocation[0];
// position[1] += childLocation[1];
// }
// child = child.getParent() instanceof View ? (View) child.getParent() : null;
// }
return position;
}
} }

View File

@ -0,0 +1,47 @@
package com.yunbao.live.viewmodel;
public class ViewPosition {
private int x;
private int y;
private int width;
private int height;
public ViewPosition(int x, int y, int width, int height) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
public int getWidth() {
return width;
}
public void setWidth(int width) {
this.width = width;
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
}

View File

@ -2822,12 +2822,12 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
newDragonGroup.setVisibility(View.VISIBLE); newDragonGroup.setVisibility(View.VISIBLE);
isDragonTime = isTime; isDragonTime = isTime;
if (isTime) { if (isTime) {
newDragonTv.setTextColor(ContextCompat.getColor(mContext, R.color.white)); // newDragonTv.setTextColor(ContextCompat.getColor(mContext, R.color.white));
// newDragonTv.clearFocus(); newDragonTv.clearFocus();
} else { } else {
newDragonTv.setTextColor(Color.parseColor("#F9BA03")); // newDragonTv.setTextColor(Color.parseColor("#F9BA03"));
newDragonTv.setText(R.string.dragon_immediate_participation); newDragonTv.setText(R.string.dragon_immediate_participation);
// newDragonTv.requestFocus(); newDragonTv.requestFocus();
} }
} }

View File

@ -17,7 +17,7 @@
<View <View
android:id="@+id/group_1" android:id="@+id/group_1"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="0dp"
android:layout_marginStart="12dp" android:layout_marginStart="12dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="3.95" app:layout_constraintDimensionRatio="3.95"
@ -112,7 +112,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:includeFontPadding="false" android:includeFontPadding="false"
android:textColor="#FFFFFF" android:textColor="#FFFFFF"
android:layout_marginTop="2dp" android:layout_marginTop="1dp"
android:textSize="8sp" android:textSize="8sp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/good_nub_ico" app:layout_constraintStart_toEndOf="@+id/good_nub_ico"

View File

@ -16,16 +16,17 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
tools:src="@mipmap/ic_live_hot_rank" tools:src="@mipmap/ic_live_hot_rank"
android:layout_marginStart="7dp" android:layout_marginStart="7dp"
android:layout_marginBottom="1dp"
android:layout_width="11dp" android:layout_width="11dp"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
<com.yunbao.common.views.weight.MarqueeTextView <com.yunbao.common.views.weight.MarqueeTextView
android:id="@+id/wish_index" android:id="@+id/wish_index"
android:layout_marginBottom="1.3dp"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/wish_pic" app:layout_constraintStart_toEndOf="@+id/wish_pic"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_marginTop="1px"
android:layout_height="wrap_content" android:layout_height="wrap_content"
tools:text="热度加成" tools:text="热度加成"
android:ellipsize="marquee" android:ellipsize="marquee"