调整趣味游戏tab选中线颜色

This commit is contained in:
zlzw 2022-10-27 10:19:50 +08:00
parent 875fa33625
commit 1d8cdf250d
2 changed files with 11 additions and 3 deletions

View File

@ -66,6 +66,7 @@ public class LiveGameDialogFragment extends AbsDialogFragment {
private String roomId; private String roomId;
private TabLayout tabLayout; private TabLayout tabLayout;
private int tabIndex = 0; private int tabIndex = 0;
private LinearLayout layout;
public LiveGameDialogFragment() { public LiveGameDialogFragment() {
@ -110,6 +111,7 @@ public class LiveGameDialogFragment extends AbsDialogFragment {
super.onActivityCreated(savedInstanceState); super.onActivityCreated(savedInstanceState);
mWebView = (WebView) findViewById(R.id.rlWebview); mWebView = (WebView) findViewById(R.id.rlWebview);
tabLayout = (TabLayout) findViewById(R.id.tabLayout); tabLayout = (TabLayout) findViewById(R.id.tabLayout);
layout = (LinearLayout) findViewById(R.id.bg_layout);
mWebView.addJavascriptInterface(new JsInteration(), "androidObject"); mWebView.addJavascriptInterface(new JsInteration(), "androidObject");
mWebView.getSettings().setJavaScriptEnabled(true); mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setDomStorageEnabled(true); mWebView.getSettings().setDomStorageEnabled(true);
@ -190,9 +192,11 @@ public class LiveGameDialogFragment extends AbsDialogFragment {
if (model != null) { if (model != null) {
if (!StringUtil.isEmpty(model.getBgColor()) && !"#".equals(model.getBgColor())) { if (!StringUtil.isEmpty(model.getBgColor()) && !"#".equals(model.getBgColor())) {
tabLayout.setBackgroundColor(Color.parseColor(model.getBgColor())); tabLayout.setBackgroundColor(Color.parseColor(model.getBgColor()));
layout.setBackgroundColor(Color.parseColor(model.getBgColor()));
} }
if (!StringUtil.isEmpty(model.getTextColor()) && !"#".equals(model.getTextColor())) { if (!StringUtil.isEmpty(model.getTextColor()) && !"#".equals(model.getTextColor())) {
tabLayout.setTabTextColors(Color.parseColor("#B3FFFFFF"), Color.parseColor(model.getTextColor())); tabLayout.setTabTextColors(Color.parseColor("#B3FFFFFF"), Color.parseColor(model.getTextColor()));
tabLayout.setSelectedTabIndicatorColor(Color.parseColor(model.getTextColor()));
} }
String url = model.getActiveSrc(); String url = model.getActiveSrc();
if (!url.startsWith("http")) { if (!url.startsWith("http")) {

View File

@ -9,18 +9,22 @@
<LinearLayout <LinearLayout
android:id="@+id/bg_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical">
<com.google.android.material.tabs.TabLayout <com.google.android.material.tabs.TabLayout
android:id="@+id/tabLayout" android:id="@+id/tabLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="40dp" android:layout_height="40dp"
app:tabMaxWidth="100dp" android:layout_marginBottom="10dp"
app:tabMode="scrollable"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"> app:layout_constraintTop_toTopOf="parent"
app:tabIndicatorFullWidth="false"
app:tabMaxWidth="100dp"
app:tabMode="scrollable">
</com.google.android.material.tabs.TabLayout> </com.google.android.material.tabs.TabLayout>