Commit 542e90fe authored by mengcuiguang's avatar mengcuiguang

代码优化

parent b96018f9
package com.mints.helivideo.ui.widgets.luckymonkeypanel;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
......@@ -8,6 +9,8 @@ import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.core.content.ContextCompat;
import com.mints.helivideo.R;
/**
......@@ -19,6 +22,8 @@ public class PanelItemView extends FrameLayout implements ItemView {
private View overlay;
private TextView tv_panel_item_text;
private ImageView iv_panel_item_pic;
private Drawable drawable;
private Drawable drawable2;
public PanelItemView(Context context) {
this(context, null);
......@@ -34,6 +39,8 @@ public class PanelItemView extends FrameLayout implements ItemView {
overlay = findViewById(R.id.overlay);
iv_panel_item_pic = findViewById(R.id.iv_panel_item_pic);
tv_panel_item_text = findViewById(R.id.tv_panel_item_text);
drawable = ContextCompat.getDrawable(getContext(), R.drawable.bg_lucky_monkey_item_overlay);
drawable2 = ContextCompat.getDrawable(getContext(), R.drawable.bg_lucky_monkey_item_overlay2);
}
public void setStyle(String type, String text) {
......@@ -50,7 +57,9 @@ public class PanelItemView extends FrameLayout implements ItemView {
@Override
public void setFocus(boolean isFocused) {
if (overlay != null) {
overlay.setVisibility(isFocused ? INVISIBLE : VISIBLE);
// overlay.setVisibility(isFocused ? INVISIBLE : VISIBLE);
overlay.setBackground(isFocused ? drawable : drawable2);
}
}
......
package com.mints.helivideo.ui.widgets.luckymonkeypanel;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
......@@ -8,6 +9,8 @@ import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.core.content.ContextCompat;
import com.mints.helivideo.R;
/**
......@@ -19,6 +22,8 @@ public class PanelItemView2 extends FrameLayout implements ItemView {
private View overlay;
private TextView tv_panel_item_text;
private ImageView iv_panel_item_pic;
private Drawable drawable;
private Drawable drawable2;
public PanelItemView2(Context context) {
this(context, null);
......@@ -34,6 +39,8 @@ public class PanelItemView2 extends FrameLayout implements ItemView {
overlay = findViewById(R.id.overlay);
iv_panel_item_pic = findViewById(R.id.iv_panel_item_pic);
tv_panel_item_text = findViewById(R.id.tv_panel_item_text);
drawable = ContextCompat.getDrawable(getContext(), R.drawable.bg_lucky_monkey_item_overlay);
drawable2 = ContextCompat.getDrawable(getContext(), R.drawable.bg_lucky_monkey_item_overlay2);
}
public void setStyle(String type, String text) {
......@@ -50,7 +57,9 @@ public class PanelItemView2 extends FrameLayout implements ItemView {
@Override
public void setFocus(boolean isFocused) {
if (overlay != null) {
overlay.setVisibility(isFocused ? INVISIBLE : VISIBLE);
// overlay.setVisibility(isFocused ? INVISIBLE : VISIBLE);
overlay.setBackground(isFocused ? drawable : drawable2);
}
}
......
......@@ -2,7 +2,7 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#30000000" />
<solid android:color="#80000000" />
<corners android:radius="10dp" />
</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/full_transparent" />
<corners android:radius="10dp" />
</shape>
\ No newline at end of file
......@@ -36,8 +36,7 @@
<View
android:id="@+id/overlay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_lucky_monkey_item_overlay" />
android:layout_height="match_parent" />
</RelativeLayout>
......
......@@ -35,8 +35,7 @@
<View
android:id="@+id/overlay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_lucky_monkey_item_overlay" />
android:layout_height="match_parent" />
</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