前排列三走势图带连线专点的方案有哪些

Android(2)
这是我第二篇CSDN文章了,写这篇文章的时候,心态已经发生了些变化。因为最近看了一个朋友介绍的一本书《奇特的一生》。在很多人看来,书中的主人翁柳比歇夫生活、工作的方法饱受争议。但是,在我看来,如果一个普通人,想要在一生之中有点成就,想要给这个世界留点什么有价值的东西,柳比歇夫的方法或许可以起到很大的作用。当我尝试去按照他的方法去做的时候,我的内心变得很纯净,丝毫不受外界各种琐碎之事的影响。另外看过一本书里面的一句话:当你安静的时候,智慧就会升起来。所以,在很多的时候,我就会去静静的思考,思考多了,慢慢地就看开了一些事情,对时间、生命的本质也会有自己的理解。闲话扯远了,今天我想要给大家带来的是关于纯代码实现的简易的的走势图。下面是效果图:
1.为了减轻我们UI的压力,我们只出了一套图片是针对分辨率为,这样为了解决屏幕的适配的问题,我们必须对不同的手机的屏幕的分辨率对图片进行处理。下面是对控件加载显示的核心的类:
package com.poker175.
import java.io.F
import java.lang.ref.WeakR
import java.math.BigI
import java.net.URLE
import java.security.MessageD
import java.security.NoSuchAlgorithmE
import java.util.WeakHashM
import android.app.A
import android.app.S
import android.content.C
import android.content.pm.ApplicationI
import android.content.pm.PackageI
import android.content.pm.PackageM
import android.graphics.B
import android.graphics.T
import android.os.Build.VERSION;
import android.os.B
import android.os.E
import android.os.H
import android.os.M
import android.telephony.TelephonyM
import android.text.TextU
import android.util.DisplayM
import android.util.L
import android.util.TypedV
import android.view.D
import android.view.V
import android.view.ViewG
import android.view.ViewGroup.LayoutP
import android.view.WindowM
import android.widget.FrameL
import android.widget.LinearL
import android.widget.RadioB
import android.widget.RelativeL
import android.widget.TextV
import com.poker175.util.StringU
import static android.content.Context.WINDOW_SERVICE;
public class BaseCommand {
public static String verN
public static int verC
public static S
public static S
public static S
public static int
public static S
public static S
public static S
public static int sW;
public static int sH;
public static String duoapp_
public static String sdkV
public static float radio = 1, radio1 = 1, radio_s = 1;
public static float radioH;
public static float radioW;
public static int deltaX = 0;
public static int deltaY = 0;
public static float W = 1280.F;
public static float H = 720.F;
static WeakHashMap&String, WeakReference&Bitmap&& bmpCacheMap = new WeakHashMap&String, WeakReference&Bitmap&&();
public static void getDeviceInfo(Activity a) {
if (TextUtils.isEmpty(verName)) {
PackageManager pm = a.getPackageManager();
PackageInfo info = pm.getPackageInfo(a.getPackageName(), 0);
pkg = info.applicationInfo.packageN
verName = info.versionN
verCode = info.versionC
TelephonyManager tm = (TelephonyManager) a
.getSystemService(Context.TELEPHONY_SERVICE);
imei = tm.getDeviceId();
imsi = tm.getSubscriberId();
phone = tm.getLine1Number();
sim = tm.getSimSerialNumber();
osver = VERSION.SDK_INT;
model = android.os.Build.MODEL;
DisplayMetrics dm = new DisplayMetrics();
a.getWindowManager().getDefaultDisplay().getMetrics(dm);
sW = dm.widthP
sH = dm.heightP
float scaleX = (float) sW / 1280;
float scaleY = (float) sH / 720;
radio = scaleX &= scaleY ? scaleY : scaleX;
duoapp_channelid = DuoCommond.duoapp_
sdkVercode = DuoCommond.sdkV
} catch (Exception ex) {
ex.printStackTrace();
public static void getDeviceInfo(Service a) {
if (TextUtils.isEmpty(verName)) {
PackageManager pm = a.getPackageManager();
PackageInfo info = pm.getPackageInfo(a.getPackageName(), 0);
pkg = info.applicationInfo.packageN
verName = info.versionN
verCode = info.versionC
TelephonyManager tm = (TelephonyManager) a
.getSystemService(Context.TELEPHONY_SERVICE);
imei = tm.getDeviceId();
imsi = tm.getSubscriberId();
phone = tm.getLine1Number();
sim = tm.getSimSerialNumber();
osver = VERSION.SDK_INT;
model = android.os.Build.MODEL;
WindowManager wm = (WindowManager) a.getSystemService(WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
DisplayMetrics dm = new DisplayMetrics();
display.getMetrics(dm);
sW = dm.widthP
sH = dm.heightP
duoapp_channelid = DuoCommond.duoapp_
sdkVercode = DuoCommond.sdkV
} catch (Exception ex) {
ex.printStackTrace();
public static String getMeataStringData(Context context, String name) {
ApplicationInfo ai = context.getPackageManager()
.getApplicationInfo(context.getPackageName(),
PackageManager.GET_META_DATA);
Bundle bundle = ai.metaD
return bundle.getString(name);
} catch (Exception e) {
return "";
public static int getMeataIntData(Context context, String name) {
ApplicationInfo ai = context.getPackageManager()
.getApplicationInfo(context.getPackageName(),
PackageManager.GET_META_DATA);
Bundle bundle = ai.metaD
return bundle.getInt(name, 0);
} catch (Exception e) {
public static String getCachePath(Context context, String dir) {
String path = null;
if (TextUtils.isEmpty(dir))
dir = context.getPackageName();
String tmp = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(tmp)) {
path = Environment.getExternalStorageDirectory().getPath() + "/"
+ dir + "/";
File file = new File(path);
if (!file.exists()) {
file.mkdir();
file = null;
path = context.getCacheDir().getAbsolutePath() + File.
public static String appendUrl(String url) {
String newurl =
newurl = StringUtil.appendNameValue(newurl, "duoid", duoapp_channelid);
newurl = StringUtil.appendNameValue(newurl, "sdkVercode", sdkVercode);
newurl = StringUtil.appendNameValue(newurl, "lang", StringUtil.getLocaleLanguage());
newurl = StringUtil.appendNameValue(newurl, "width", String.valueOf(sW));
newurl = StringUtil.appendNameValue(newurl, "height",
String.valueOf(sH));
newurl = StringUtil.appendNameValue(newurl, "ver", verName);
newurl = StringUtil.appendNameValue(newurl, "vercode",
String.valueOf(verCode));
newurl = StringUtil.appendNameValue(newurl, "imei", imei);
newurl = StringUtil.appendNameValue(newurl, "imsi", imsi);
newurl = StringUtil.appendNameValue(newurl, "osver",
String.valueOf(osver));
newurl = StringUtil.appendNameValue(newurl, "pkg", pkg);
if (!TextUtils.isEmpty(model))
newurl = StringUtil.appendNameValue(newurl, "model",
URLEncoder.encode(model));
newurl = StringUtil.appendNameValue(newurl, "phone", phone == null ? ""
: URLEncoder.encode(phone));
newurl = StringUtil.appendNameValue(newurl, "sim", sim == null ? ""
: URLEncoder.encode(sim));
public static String getMd5Hash(String input) {
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] messageDigest = md.digest(input.getBytes());
BigInteger number = new BigInteger(1, messageDigest);
String md5 = number.toString(16);
return md5;
} catch (NoSuchAlgorithmException e) {
return null;
public static void sendProcessingMessage(Handler handler) {
Message msg = new Message();
Bundle b = new Bundle();
b.putInt(BaseContant.MESSAGE_DATA_RESULT,
BaseContant.MESSAGE_PROCESSINGFLAG);
msg.setData(b);
handler.sendMessage(msg);
public static void sendProcessedMessage(Handler handler, int pageid,
String url, boolean isClear, boolean isRefresh, boolean isRemote) {
Message msg = new Message();
Bundle b = new Bundle();
b.putInt(BaseContant.MESSAGE_DATA_RESULT,
BaseContant.MESSAGE_PROCESSEDFLAG);
b.putString(BaseContant.MESSAGE_URL_RESULT, url);
b.putInt(BaseContant.MESSAGE_PAGEID_RESULT, pageid);
b.putBoolean(BaseContant.MESSAGE_ISCLEAR_RESULT, isClear);
b.putBoolean(BaseContant.MESSAGE_ISREFRESH_RESULT, isRefresh);
b.putBoolean(BaseContant.MESSAGE_ISREMOTE_RESULT, isRemote);
msg.setData(b);
handler.sendMessage(msg);
* 清理早于指定的时间的问题
public static void clearSavedFile(String rootPath, int day) {
File dir = new File(rootPath);
String[] filenames = dir.list();
if (filenames == null)
long m1 = day * ;
long m2 = System.currentTimeMillis();
long m = m2 - m1;
for (String filename : filenames) {
String[] tmp = filename.split("_");
if (tmp.length == 2 && TextUtils.isDigitsOnly(tmp[1])) {
long m3 = Long.parseLong(tmp[1]);
if (m & m3) {
File file = new File(rootPath + filename);
file.delete();
file = null;
} else if (!filename.toLowerCase().endsWith(".apk")
&& !filename.toLowerCase().endsWith(".ap0")) {
File file = new File(rootPath + filename);
file.delete();
* 删除下载在手机中(非SDCARD)的安装包
public static void clearDownedTempFile(Context context) {
File file = context.getFilesDir();
for (String filename : file.list()) {
if (filename.startsWith("sharetemp_")) {
context.deleteFile(filename);
* 重置控件宽高
public static void setViewWH(View view, float w, float h) {
LayoutParams para = view.getLayoutParams();
para.width = (int) (w * BaseCommond.radio);
para.height = (int) (h * BaseCommond.radio);
view.setLayoutParams(para);
* 适配控件相关宽高
* container
* leftMargin 以屏幕左上角为原点 的左边距
* topMargin
以屏幕左上角为原点 的上边距
是否为根容器
public static void setPositionAndWH(ViewGroup container, View view, int w, int h,
int leftMargin, int topMargin, Boolean isRoot) {
FrameLayout.LayoutParams layoutP
layoutParams = new FrameLayout.LayoutParams((int) (w * radio_s),
(int) (h * radio_s));
if (isRoot) {
layoutParams.leftMargin = (int) (leftMargin * radio_s) + deltaX;
layoutParams.topMargin = (int) (topMargin * radio_s) + deltaY;
layoutParams.leftMargin = (int) (leftMargin * radio_s);
layoutParams.topMargin = (int) (topMargin * radio_s);
container.addView(view, layoutParams);
* 设置大厅的玩家的位置和大小
* container
* leftMargin
* topMargin
public static void setNewHallPlayerInfoAndWH(ViewGroup container, View view, int w, int h,
int leftMargin, int topMargin, Boolean isRoot) {
FrameLayout.LayoutParams layoutP
layoutParams = new FrameLayout.LayoutParams((int) (w * radio_s),
(int) (h * radio_s));
if (isRoot) {
layoutParams.leftMargin = (int) (leftMargin * radio_s) + deltaX;
layoutParams.topMargin = (int) (topMargin * radio_s) + deltaY;
layoutParams.leftMargin = (int) (leftMargin * radio_s);
if (radioH == radioW) {
layoutParams.topMargin = (int) (topMargin * radio_s);
layoutParams.topMargin = (int) (topMargin * radio_s / 1.4);
container.addView(view, layoutParams);
* 设置万人场的底部的玩家的位置和大小
* container
* leftMargin
* topMargin
public static void setWanrenBottomPlayerInfo(ViewGroup container, View view, int w, int h,
int leftMargin, int topMargin, Boolean isRoot) {
FrameLayout.LayoutParams layoutP
layoutParams = new FrameLayout.LayoutParams((int) (w * radio_s),
(int) (h * radio_s));
if (isRoot) {
layoutParams.leftMargin = (int) (leftMargin * radio_s) + deltaX;
layoutParams.topMargin = (int) (topMargin * radio_s) + deltaY;
layoutParams.leftMargin = (int) (leftMargin * radio_s);
if (radioH == radioW) {
layoutParams.topMargin = (int) (topMargin * radio_s);
layoutParams.topMargin = (int) (topMargin * radioH);
container.addView(view, layoutParams);
* 设置今日活动的RadioButton的位置和大小
* container
* leftMargin
* topMargin
public static void setRadioButtonPositionAndWH(ViewGroup container, View view, int w, int h,
int leftMargin, int topMargin, Boolean isRoot) {
FrameLayout.LayoutParams layoutP
layoutParams = new FrameLayout.LayoutParams((int) (w * radio_s),
(int) (h * radio_s));
if (isRoot) {
layoutParams.leftMargin = (int) (leftMargin * radio_s) + deltaX;
layoutParams.topMargin = (int) (topMargin * radio_s) + deltaY;
layoutParams.leftMargin = (int) (leftMargin * radio_s);
if (radioH == radioW) {
layoutParams.topMargin = (int) (topMargin * radio_s);
layoutParams.topMargin = topM
container.addView(view, layoutParams);
* 设置顶部的广播和消息的位置和大小
* container
* leftMargin
* topMargin
public static void setTopBroadcastMessageAndWH(ViewGroup container, View view, int w, int h,
int leftMargin, int topMargin, Boolean isRoot) {
RelativeLayout.LayoutParams layoutP
layoutParams = new RelativeLayout.LayoutParams((int) (w * radio_s),
(int) (h * radio_s));
if (isRoot) {
layoutParams.leftMargin = (int) (leftMargin * radio_s) + deltaX;
layoutParams.leftMargin = (int) (leftMargin * radio_s);
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
container.addView(view, layoutParams);
* 设置底部的菜单的位置和大小
* container
* leftMargin
* topMargin
public static void setBottomMenuPositionAndWH(ViewGroup container, View view, int w, int h,
int leftMargin, int topMargin, Boolean isRoot) {
RelativeLayout.LayoutParams layoutP
layoutParams = new RelativeLayout.LayoutParams((int) (w * radio_s),
(int) (h * radio_s));
if (isRoot) {
layoutParams.leftMargin = (int) (leftMargin * radio_s) + deltaX;
layoutParams.leftMargin = (int) (leftMargin * radio_s);
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
container.addView(view, layoutParams);
* 设置大厅消息和客服消息的位置和大小
* container
* leftMargin
* topMargin
public static void setHallServiceMessageAndWH(ViewGroup container, View view, int w, int h,
int leftMargin, int topMargin, Boolean isRoot) {
FrameLayout.LayoutParams layoutP
layoutParams = new FrameLayout.LayoutParams((int) (w * radio_s),
(int) (h * radio_s));
if (isRoot) {
layoutParams.leftMargin = (int) (leftMargin * radio_s) + deltaX;
layoutParams.topMargin = (int) (topMargin * radio_s) + deltaY;
layoutParams.leftMargin = (int) (leftMargin * radio_s);
if (radioH == radioW) {
layoutParams.topMargin = (int) (topMargin * radio_s);
layoutParams.topMargin = (int) (topMargin * radioH);
container.addView(view, layoutParams);
public static void reSetPositionAndWH(ViewGroup container, View view, View newView,
int w, int h, int leftMargin, int topMargin, Boolean isRoot) {
if (view != null) {
container.removeView(view);
FrameLayout.LayoutParams layoutP
layoutParams = new FrameLayout.LayoutParams((int) (w * radio_s),
(int) (h * radio_s));
if (isRoot) {
layoutParams.leftMargin = (int) (leftMargin * radio_s) + deltaX;
layoutParams.topMargin = (int) (topMargin * radio_s) + deltaY;
layoutParams.leftMargin = (int) (leftMargin * radio_s);
layoutParams.topMargin = (int) (topMargin * radio_s);
container.addView(newView, layoutParams);
* 适配控件相关宽高
* container
* leftMargin 以屏幕左上角为原点 的左边距
* topMargin
以屏幕左上角为原点 的上边距
* textSize
是否为根容器
public static void setPositionAndWH(ViewGroup container, View view, int w, int h,
int leftMargin, int topMargin, int textSize, Boolean isRoot) {
FrameLayout.LayoutParams layoutP
layoutParams = new FrameLayout.LayoutParams((int) (w * radio_s),
(int) (h * radio_s));
if (isRoot) {
layoutParams.leftMargin = (int) (leftMargin * radio_s) + deltaX;
layoutParams.topMargin = (int) (topMargin * radio_s) + deltaY;
layoutParams.leftMargin = (int) (leftMargin * radio_s);
layoutParams.topMargin = (int) (topMargin * radio_s);
if (textSize & 0) {
if (view instanceof TextView) {
((TextView) view).setTextSize(TypedValue.COMPLEX_UNIT_PX,
textSize * radio_s);
((TextView) view).setTypeface(Typeface
.defaultFromStyle(Typeface.BOLD));
} else if (view instanceof RadioButton) {
((RadioButton) view).setTextSize(TypedValue.COMPLEX_UNIT_PX,
textSize * radio_s);
container.addView(view, layoutParams);
* 适配控件相关宽高
* container
* leftMargin 以屏幕左上角为原点 的左边距
* topMargin
以屏幕左上角为原点 的上边距
* textSize
是否为根容器
public static void setMsgPositionAndWH(ViewGroupcontainer, View view, int w, int h,int leftMargin, int topMargin, int textSize, Boolean isRoot) {
FrameLayout.LayoutParams layoutP
layoutParams = new FrameLayout.LayoutParams((int)
(w * radio_s), (int) (h * radio_s));
if (isRoot) {
layoutParams.leftMargin = (int) (leftMargin *
radio_s) + deltaX;
layoutParams.topMargin = (int) (topMargin * radio_s) + deltaY;
if (radioH == radio) {
layoutParams.leftMargin = (int) (leftMargin * radio_s);
layoutParams.topMargin = (int) (topMargin * radio_s);
layoutParams.leftMargin = (int) (leftMargin * radio_s);
layoutParams.topMargin = (int) (topMargin * radio_s) + 50;
if (textSize & 0) {
if (view instanceof TextView) {
((TextView) view).setTextSize(TypedValue.COMPLEX_UNIT_PX,
textSize * radio_s);
((TextView) view).setTypeface(Typeface
.defaultFromStyle(Typeface.BOLD));
} else if (view instanceof RadioButton) {
((RadioButton) view).setTextSize(TypedValue.COMPLEX_UNIT_PX,
textSize * radio_s);
container.addView(view, layoutParams);
* 设置首页的大厅的玩家的信息的位置和大小
* container
* leftMargin
* topMargin
* textSize
public static void setNewHallPlayerInfoAndWH(ViewGroup container, View view, int w, int h,
int leftMargin, int topMargin, int textSize, Boolean isRoot) {
FrameLayout.LayoutParams layoutP
layoutParams = new FrameLayout.LayoutParams((int) (w * radio_s),
(int) (h * radio_s));
if (isRoot) {
layoutParams.leftMargin = (int) (leftMargin * radio_s) + deltaX;
layoutParams.topMargin = (int) (topMargin * radio_s) + deltaY;
layoutParams.leftMargin = (int) (leftMargin * radio_s);
if (radioW == radioH) {
layoutParams.topMargin = (int) (topMargin * radio_s);
layoutParams.topMargin = (int) (topMargin * radio_s / 1.4);
if (textSize & 0) {
if (view instanceof TextView) {
((TextView) view).setTextSize(TypedValue.COMPLEX_UNIT_PX,
textSize * radio_s);
((TextView) view).setTypeface(Typeface
.defaultFromStyle(Typeface.BOLD));
} else if (view instanceof RadioButton) {
((RadioButton) view).setTextSize(TypedValue.COMPLEX_UNIT_PX,
textSize * radio_s);
container.addView(view, layoutParams);
* container
* leftMargin
* topMargin
* textSize
public static void setWanrenBottomPlayerInfo(ViewGroup container, View view, int w, int h,
int leftMargin, int topMargin, int textSize, Boolean isRoot) {
FrameLayout.LayoutParams layoutP
layoutParams = new FrameLayout.LayoutParams((int) (w * radio_s),
(int) (h * radio_s));
if (isRoot) {
layoutParams.leftMargin = (int) (leftMargin * radio_s) + deltaX;
layoutParams.topMargin = (int) (topMargin * radio_s) + deltaY;
layoutParams.leftMargin = (int) (leftMargin * radio_s);
if (radioH == radioW) {
layoutParams.topMargin = (int) (topMargin * radio_s);
layoutParams.topMargin = (int) (topMargin * radioH);
if (textSize & 0) {
if (view instanceof TextView) {
((TextView) view).setTextSize(TypedValue.COMPLEX_UNIT_PX,
textSize * radio_s);
((TextView) view).setTypeface(Typeface
.defaultFromStyle(Typeface.BOLD));
} else if (view instanceof RadioButton) {
((RadioButton) view).setTextSize(TypedValue.COMPLEX_UNIT_PX,
textSize * radio_s);
container.addView(view, layoutParams);
* 设置购物车中心的RadioButton的位置和大小
* container
* leftMargin
* textSize
public static void setShoppingCartRadioButtonAndWH(ViewGroup container, View view, int w, int h,
int leftMargin, int textSize, Boolean isRoot) {
FrameLayout.LayoutParams layoutP
layoutParams = new FrameLayout.LayoutParams((int) (w * radio_s),
(int) (h * radio_s));
if (isRoot) {
layoutParams.leftMargin = (int) (leftMargin * radio_s) + deltaX;
layoutParams.leftMargin = (int) (leftMargin * radio_s);
if (textSize & 0) {
if (view instanceof TextView) {
((TextView) view).setTextSize(TypedValue.COMPLEX_UNIT_PX,
textSize * radio_s);
((TextView) view).setTypeface(Typeface
.defaultFromStyle(Typeface.BOLD));
} else if (view instanceof RadioButton) {
((RadioButton) view).setTextSize(TypedValue.COMPLEX_UNIT_PX,
textSize * radio_s);
container.addView(view, layoutParams);
* 设置RadioButton的大小和位置
* container
* leftMargin
* topMargin
* textSize
public static void setRadioButtonPositionAndWH(ViewGroup container, View view, int w, int h,
int leftMargin, int topMargin, int textSize, Boolean isRoot) {
FrameLayout.LayoutParams layoutP
layoutParams = new FrameLayout.LayoutParams((int) (w * radio_s),
(int) (h * radio_s));
if (isRoot) {
layoutParams.leftMargin = (int) (leftMargin * radio_s) + deltaX;
layoutParams.topMargin = (int) (topMargin * radio_s);
layoutParams.leftMargin = (int) (leftMargin * radio_s);
layoutParams.topMargin = (int) (topMargin * radio_s);
if (textSize & 0) {
if (view instanceof TextView) {
((TextView) view).setTextSize(TypedValue.COMPLEX_UNIT_PX,
textSize * radio_s);
((TextView) view).setTypeface(Typeface
.defaultFromStyle(Typeface.BOLD));
} else if (view instanceof RadioButton) {
((RadioButton) view).setTextSize(TypedValue.COMPLEX_UNIT_PX,
textSize * radio_s);
container.addView(view, layoutParams);
* 初始化屏幕适配的相关参数
从大厅开始
public static void initScreenParam(Activity act) {
DisplayMetrics dm = new DisplayMetrics();
act.getWindowManager().getDefaultDisplay().getMetrics(dm);
sW = dm.widthP
sH = dm.heightP
Log.d("Base", "sW" + sW + "sH" + sH);
radioH = sH / H;
radioW = sW / W;
if (radioH & radioW) {
deltaY = (int) ((sH - radioW * H) / 2);
radio_s = radioW;
deltaX = (int) ((sW - radioH * W) / 2);
radio_s = radioH;
* 判断系统版本是否高于3.0
public static boolean canPerformPropertyAnim() {
int API_LEVEL = VERSION.SDK_INT;
Log.i("ACT00", API_LEVEL + "");
if (API_LEVEL &= 11) {
return true;
return false;
} catch (Exception e) {
return false;
public static void setFloatPositionAndWH(ViewGroup container, View view,
int w, int h, int leftMargin,
float topMargin, Boolean isRight) {
FrameLayout.LayoutParams layoutP
layoutParams = new FrameLayout.LayoutParams(
(int) (w * BaseCommond.radio_s),
(int) (h * BaseCommond.radio_s));
if (isRight) {
layoutParams.leftMargin = (int) (leftMargin * BaseCommond.radio_s) + BaseCommond.deltaX * 2;
layoutParams.topMargin = (int) (topMargin * BaseCommond.radio_s) + BaseCommond.deltaY;
layoutParams.leftMargin = (int) (leftMargin * BaseCommond.radio_s) + BaseCommond.deltaX;
layoutParams.topMargin = (int) (topMargin * BaseCommond.radio_s) + BaseCommond.deltaY * 2;
container.addView(view, layoutParams);
* container
public static void setViewPagerFloatPositionAndWH(ViewGroup container, View view, int w, int h, boolean isRight) {
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
(int) (w * BaseCommond.radio_s),
(int) (h * BaseCommond.radio_s));
if (!isRight) {
layoutParams.rightMargin = (int) (20 * BaseCommond.radio_s);
container.addView(view, layoutParams);
* container
public static void setLeftViewPagerFloatPositionAndWH(ViewGroup container, View view, int w, int h) {
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
(int) (w * BaseCommond.radio_s),
(int) (h * BaseCommond.radio_s));
layoutParams.rightMargin = (int) (20 * BaseCommond.radio_s);
layoutParams.leftMargin = (int) (20 * BaseCommond.radio_s);
container.addView(view, layoutParams);
public static void setStorePositionAndWH(ViewGroup container, View view, int w, int h, int left, int top, int textSize) {
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
(int) (w * BaseCommond.radio_s),
(int) (h * BaseCommond.radio_s));
layoutParams.leftMargin = (int) (left * BaseCommond.radio_s);
layoutParams.topMargin = (int) (top * BaseCommond.radio_s);
if (textSize & 0) {
if (view instanceof TextView) {
((TextView) view).setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize * radio_s);
((TextView) view).setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
container.addView(view, layoutParams);
下面我对上面的类的核心的方法进行解读:
* 初始化屏幕适配的相关参数
从大厅开始
public static void initScreenParam(Activity act) {
DisplayMetrics dm = new DisplayMetrics();
act.getWindowManager().getDefaultDisplay()
.getMetrics(dm);
sW = dm.widthP
sH = dm.heightP
Log.d("Base", "sW" + sW + "sH" + sH);
radioH = sH / H;
radioW = sW / W;
if (radioH & radioW) {
deltaY = (int) ((sH - radioW * H) / 2);
radio_s = radioW;
deltaX = (int) ((sW - radioH * W) / 2);
radio_s = radioH;
1.上面的方法获取手机的宽、高像素,然后跟指定为标准的宽、高进行比,求出其比例系数。取宽高比例系数较小的一个,为什么要取系数较小的一个呢?下面我们就来看看下面的图来帮助理解
2.根据图很容易就能够就明白initScreenParam方法计算像素的比例的算法,我们总是取宽或者高的比例中较小的,采取极限的思维,如果去交大的值,那么必然会导致图片的宽或者高溢出屏幕的情况发生,这样图片显示就不完整。
2.这里的第二个核心的方法就是:
* 适配控件相关宽高
* container
* leftMargin 以屏幕左上角为原点 的左边距
* topMargin
以屏幕左上角为原点 的上边距
是否为根容器
public static void setPositionAndWH(ViewGroup container, View view, int w, int h,int leftMargin, int topMargin, Boolean isRoot) {
FrameLayout.LayoutParams layoutP
layoutParams = new FrameLayout.LayoutParams((int) (w * radio_s),
(int) (h * radio_s));
if (isRoot) {
layoutParams.leftMargin = (int) (leftMargin * radio_s) + deltaX;
layoutParams.topMargin = (int) (topMargin * radio_s) + deltaY;
layoutParams.leftMargin = (int) (leftMargin * radio_s);
layoutParams.topMargin = (int) (topMargin * radio_s);
container.addView(view, layoutParams);
**3.在这里,我们所有的布局都放在FrameLayout里面,所有的空间的位置都是相对于屏幕的左上角进行测量,然后按照比例进行计算其位置以及大小。我们关注的是这个函数的参数的含义,下面简单的介绍一下:
第一个参数是容器,这里就是我们定义的xml的FrameLayout,在我们的Activity的xml中的定义:**
&?xml version="1.0" encoding="utf-8"?&
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rl_root"
android:layout_width="fill_parent"
android:layout_height="fill_parent"&
android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent"&&
后面几个参数分别是控件的引用,控件的宽、高、控件离屏幕leftMargin和topMargin,使用的方法如下:
//彩票的图标的大小和位置的设定
ImageView ivLottery = new ImageView(this)
ivLottery.setImageResource(R.drawable.lottery)
ivLottery.setId(ROOM_LOTTERY)
ivLottery.setOnClickListener(this)
BaseCommand.setPositionAndWH(root, ivLottery, 112, 86, 874, 555, false)
4.上述的是用Java代码的方式实现简易的走势图的第一步,即创建在一个控制控件在屏幕上的大小和位置的基础类。
5具体如何的实现简易的走势图,敬请期待我的下一篇文章

我要回帖

更多关于 三地走势图带连线 的文章

 

随机推荐