Commit 81d7d881 by tanghuan

调整原生的隐私政策界面

1 parent 7c1ac39c
......@@ -5,6 +5,7 @@ import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.drawable.GradientDrawable;
import android.graphics.Typeface;
import android.net.Uri;
import android.os.Bundle;
......@@ -16,6 +17,7 @@ import android.text.style.ClickableSpan;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;
......@@ -62,30 +64,37 @@ public class PrivacyActivity extends Activity {
}
private View createContentView() {
// 根布局
LinearLayout rootLayout = new LinearLayout(this);
rootLayout.setOrientation(LinearLayout.VERTICAL);
rootLayout.setGravity(Gravity.CENTER_VERTICAL);
rootLayout.setPadding(dpToPx(32), dpToPx(48), dpToPx(32), dpToPx(48));
// 外层根布局(浅灰色背景,垂直居中)
FrameLayout rootLayout = new FrameLayout(this);
rootLayout.setBackgroundColor(0xFFFFFFFF);
// 内容容器
LinearLayout contentLayout = new LinearLayout(this);
contentLayout.setOrientation(LinearLayout.VERTICAL);
LinearLayout.LayoutParams contentLayoutParams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
rootLayout.addView(contentLayout, contentLayoutParams);
// 卡片容器(白色圆角卡片)
LinearLayout cardLayout = new LinearLayout(this);
cardLayout.setOrientation(LinearLayout.VERTICAL);
cardLayout.setPadding(dpToPx(28), dpToPx(36), dpToPx(28), dpToPx(36));
GradientDrawable cardBg = new GradientDrawable();
cardBg.setColor(0xFFFFFFFF);
cardBg.setCornerRadius(dpToPx(16));
cardLayout.setBackground(cardBg);
FrameLayout.LayoutParams cardParams = new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.WRAP_CONTENT);
int cardMarginH = dpToPx(24);
int cardMarginV = dpToPx(80);
cardParams.setMargins(cardMarginH, cardMarginV, cardMarginH, cardMarginV);
cardParams.gravity = Gravity.CENTER_VERTICAL;
rootLayout.addView(cardLayout, cardParams);
// 标题
TextView titleView = new TextView(this);
titleView.setText("用户协议与隐私政策");
titleView.setTextSize(22);
titleView.setTextSize(23);
titleView.setTextColor(0xFF333333);
titleView.setTypeface(null, Typeface.BOLD);
titleView.setGravity(Gravity.CENTER);
titleView.setPadding(0, 0, 0, dpToPx(32));
contentLayout.addView(titleView);
titleView.setPadding(0, 0, 0, dpToPx(28));
cardLayout.addView(titleView);
// 内容(带可点击链接)
TextView contentView = new TextView(this);
......@@ -93,10 +102,10 @@ public class PrivacyActivity extends Activity {
contentView.setMovementMethod(LinkMovementMethod.getInstance());
contentView.setHighlightColor(0x00000000);
contentView.setTextSize(17);
contentView.setTextColor(0xFF666666);
contentView.setTextColor(0xFF555555);
contentView.setLineSpacing(dpToPx(6), 1.0f);
contentView.setGravity(Gravity.START);
contentLayout.addView(contentView);
cardLayout.addView(contentView);
// 按钮容器
LinearLayout buttonLayout = new LinearLayout(this);
......@@ -105,45 +114,51 @@ public class PrivacyActivity extends Activity {
LinearLayout.LayoutParams buttonLayoutParams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
buttonLayoutParams.topMargin = dpToPx(48);
contentLayout.addView(buttonLayout, buttonLayoutParams);
buttonLayoutParams.topMargin = dpToPx(32);
cardLayout.addView(buttonLayout, buttonLayoutParams);
int btnHeight = dpToPx(44);
int btnRadius = dpToPx(22);
// 同意按钮
// 同意按钮(蓝紫色填充,大圆角)
Button agreeButton = new Button(this);
agreeButton.setText("同意");
agreeButton.setTextColor(0xFFFFFFFF);
agreeButton.setBackgroundColor(0xFF4CAF50);
agreeButton.setTextSize(16);
agreeButton.setTypeface(null, Typeface.BOLD);
agreeButton.setGravity(Gravity.CENTER);
agreeButton.setSingleLine(true);
agreeButton.setMinWidth(dpToPx(120));
agreeButton.setMinHeight(dpToPx(48));
int btnPaddingH = dpToPx(24);
int btnPaddingV = dpToPx(12);
agreeButton.setPadding(btnPaddingH, btnPaddingV, btnPaddingH, btnPaddingV);
agreeButton.setPadding(0, 0, 0, 0);
GradientDrawable agreeBg = new GradientDrawable();
agreeBg.setColor(0xFF7691FA);
agreeBg.setCornerRadius(btnRadius);
agreeButton.setBackground(agreeBg);
agreeButton.setOnClickListener(v -> onAgreeClicked());
LinearLayout.LayoutParams agreeParams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
agreeParams.setMargins(dpToPx(16), 0, dpToPx(16), 0);
0,
btnHeight,
1.0f);
agreeParams.setMargins(0, 0, dpToPx(8), 0);
buttonLayout.addView(agreeButton, agreeParams);
// 不同意按钮
// 不同意按钮(灰色描边,大圆角)
Button disagreeButton = new Button(this);
disagreeButton.setText("不同意");
disagreeButton.setTextColor(0xFF666666);
disagreeButton.setBackgroundColor(0xFFEEEEEE);
disagreeButton.setTextSize(16);
disagreeButton.setGravity(Gravity.CENTER);
disagreeButton.setSingleLine(true);
disagreeButton.setMinWidth(dpToPx(120));
disagreeButton.setMinHeight(dpToPx(48));
disagreeButton.setPadding(btnPaddingH, btnPaddingV, btnPaddingH, btnPaddingV);
disagreeButton.setPadding(0, 0, 0, 0);
GradientDrawable disagreeBg = new GradientDrawable();
disagreeBg.setColor(0xFFF5F6FA);
disagreeBg.setCornerRadius(btnRadius);
disagreeButton.setBackground(disagreeBg);
disagreeButton.setOnClickListener(v -> onDisagreeClicked());
LinearLayout.LayoutParams disagreeParams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
disagreeParams.setMargins(dpToPx(16), 0, dpToPx(16), 0);
0,
btnHeight,
1.0f);
disagreeParams.setMargins(dpToPx(8), 0, 0, 0);
buttonLayout.addView(disagreeButton, disagreeParams);
return rootLayout;
......@@ -172,7 +187,7 @@ public class PrivacyActivity extends Activity {
@Override
public void updateDrawState(TextPaint ds) {
super.updateDrawState(ds);
ds.setColor(0xFF4CAF50);
ds.setColor(0xFF7691FA);
ds.setUnderlineText(true);
}
}, userAgreementStart, userAgreementEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
......@@ -188,7 +203,7 @@ public class PrivacyActivity extends Activity {
@Override
public void updateDrawState(TextPaint ds) {
super.updateDrawState(ds);
ds.setColor(0xFF4CAF50);
ds.setColor(0xFF7691FA);
ds.setUnderlineText(true);
}
}, privacyPolicyStart, privacyPolicyEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!