分辨率适配的步骤

分辨率适配的方法它解决了分辨率跟密集度的关系,但是也引来一个问题,就是布局会因为图片资源小而失真,所以

分辨率适配的方法

它解决了分辨率跟密集度的关系,但是也引来一个问题,就是布局会因为图片资源小而失真,所以这也需要美工的同志多多配合的,贴代码:

第一步,先创建一个view信息的javabean类:



  1. package com.zte.layout.adapter;

  2. import android.view.View;

  3. /**
  4. * 存储View信息的JavaBean类
  5. * 
  6. * @author 
  7. * 
  8. */
  9. public class LayoutInformation
  10. {
  11.         /**
  12.          * View的对象
  13.          */
  14.         private View view;

  15.         /**
  16.          * View的宽度
  17.          */
  18.         private double viewWidth;

  19.         /**
  20.          * View的高度
  21.          */
  22.         private double viewHeight;

  23.         /**
  24.          * View距左边的距离,即marginLeft
  25.          */
  26.         private double viewMarginLeft;

  27.         /**
  28.          * View距顶部的距离,即MarginTop;
  29.          */
  30.         private double viewMarginTop;
  31.         
  32.         /**
  33.          * 父类布局的类型为相对布局
  34.          */
  35.         public static int R=-1;
  36.         
  37.         /**
  38.          * 父类布局的类型为线性布局
  39.          */
  40.         public static int L=-2;
  41.         
  42.         /**
  43.          * 此View的父类布局的类型
  44.          */
  45.         private int parentLayoutType;

  46.         /**
  47.          * 存储View信息的JavaBean类
  48.          * 
  49.          * @param view
  50.          *            View的对象
  51.          * @param viewWidth
  52.          *            View的宽
  53.          * @param viewHeight
  54.          *            View的高
  55.          * @param viewMarginLeft
  56.          *            View距左边的距离
  57.          * @param viewMargdoubleop
  58.          *            View距上部的距离
  59.          * @param parentLayoutType
  60.          *            父类布局的类型,LayoutInformation.R
  61.          *            (表示相对布局)或者LayoutInformation.L(表示线性布局)
  62.          */
  63.         public LayoutInformation(View view, double viewWidth, double viewHeight,
  64.                         double viewMarginLeft, double viewMarginTop, int parentLayoutType)
  65.         {

  66.                 this.view = view;
  67.                 this.viewWidth = viewWidth;
  68.                 this.viewHeight = viewHeight;
  69.                 this.viewMarginLeft = viewMarginLeft;
  70.                 this.viewMarginTop = viewMarginTop;
  71.                 this.parentLayoutType=parentLayoutType;
  72.         }

  73.         /**
  74.          * 获取View的对象
  75.          * 
  76.          * [url=home.php?mod=space&uid=7300]@return[/url] View对象
  77.          */
  78.         public View getView()
  79.         {
  80.                 return view;
  81.         }

  82.         /**
  83.          * 设置View的对象
  84.          */
  85.         public void setView(View view)
  86.         {
  87.                 this.view = view;
  88.         }

  89.         /**
  90.          * 获取View的宽度
  91.          * 
  92.          * @return View的宽度,double型
  93.          */
  94.         public double getViewWidth()
  95.         {
  96.                 return viewWidth;
  97.         }

  98.         /**
  99.          * 设置View的宽度,double型
  100.          * 
  101.          * @param viewWidth
  102.          */
  103.         public void setViewWidth(double viewWidth)
  104.         {
  105.                 this.viewWidth = viewWidth;
  106.         }

  107.         /**
  108.          * 获取View的高度
  109.          * 
  110.          * @return View的高度,double型
  111.          */
  112.         public double getViewHeight()
  113.         {
  114.                 return viewHeight;
  115.         }

  116.         /**
  117.          * 设置View的高度,double型
  118.          * 
  119.          * @param viewHeight
  120.          */
  121.         public void setViewHeight(double viewHeight)
  122.         {
  123.                 this.viewHeight = viewHeight;
  124.         }

  125.         /**
  126.          * 获取View距离左边的距离
  127.          * 
  128.          * @return View距离左边的距离,double型
  129.          */
  130.         public double getViewMarginLeft()
  131.         {
  132.                 return viewMarginLeft;
  133.         }

  134.         /**
  135.          * 设置View距离左边的距离,double型
  136.          * 
  137.          * @param viewMarginLeft
  138.          */
  139.         public void setViewMarginLeft(double viewMarginLeft)
  140.         {
  141.                 this.viewMarginLeft = viewMarginLeft;
  142.         }

  143.         /**
  144.          * 获取View距离上部的距离
  145.          * 
  146.          * @return View距离上部的距离,double型
  147.          */
  148.         public double getViewMarginTop()
  149.         {
  150.                 return viewMarginTop;
  151.         }

  152.         /**
  153.          * 设置View距离上部的距离,double型
  154.          * 
  155.          * @param viewMargdoubleop
  156.          */
  157.         public void setViewMarginTop(double viewMarginTop)
  158.         {
  159.                 this.viewMarginTop = viewMarginTop;
  160.         }
  161.         
  162.         /**
  163.          * 获取父类布局的类型
  164.          * @return parentLayoutType,int型
  165.          */
  166.         public int getParentLayoutType()
  167.         {
  168.                 return parentLayoutType;
  169.         }

  170.         /**
  171.          * 设置父类布局的类型
  172.          * @param parentLayoutType
  173.          */
  174.         public void setParentLayoutType(int parentLayoutType)
  175.         {
  176.                 this.parentLayoutType = parentLayoutType;
  177.         }

  178. }
  1. package com.zte.layout.adapter;

  2. import android.view.View;

  3. /**
  4. * 存储View信息的JavaBean类
  5. * 
  6. * @author 
  7. * 
  8. */
  9. public class LayoutInformation
  10. {
  11.         /**
  12.          * View的对象
  13.          */
  14.         private View view;

  15.         /**
  16.          * View的宽度
  17.          */
  18.         private double viewWidth;

  19.         /**
  20.          * View的高度
  21.          */
  22.         private double viewHeight;

  23.         /**
  24.          * View距左边的距离,即marginLeft
  25.          */
  26.         private double viewMarginLeft;

  27.         /**
  28.          * View距顶部的距离,即MarginTop;
  29.          */
  30.         private double viewMarginTop;
  31.         
  32.         /**
  33.          * 父类布局的类型为相对布局
  34.          */
  35.         public static int R=-1;
  36.         
  37.         /**
  38.          * 父类布局的类型为线性布局
  39.          */
  40.         public static int L=-2;
  41.         
  42.         /**
  43.          * 此View的父类布局的类型
  44.          */
  45.         private int parentLayoutType;

  46.         /**
  47.          * 存储View信息的JavaBean类
  48.          * 
  49.          * @param view
  50.          *            View的对象
  51.          * @param viewWidth
  52.          *            View的宽
  53.          * @param viewHeight
  54.          *            View的高
  55.          * @param viewMarginLeft
  56.          *            View距左边的距离
  57.          * @param viewMargdoubleop
  58.          *            View距上部的距离
  59.          * @param parentLayoutType
  60.          *            父类布局的类型,LayoutInformation.R
  61.          *            (表示相对布局)或者LayoutInformation.L(表示线性布局)
  62.          */
  63.         public LayoutInformation(View view, double viewWidth, double viewHeight,
  64.                         double viewMarginLeft, double viewMarginTop, int parentLayoutType)
  65.         {

  66.                 this.view = view;
  67.                 this.viewWidth = viewWidth;
  68.                 this.viewHeight = viewHeight;
  69.                 this.viewMarginLeft = viewMarginLeft;
  70.                 this.viewMarginTop = viewMarginTop;
  71.                 this.parentLayoutType=parentLayoutType;
  72.         }

  73.         /**
  74.          * 获取View的对象
  75.          * 
  76.          * [url=home.php?mod=space&uid=7300]@return[/url] View对象
  77.          */
  78.         public View getView()
  79.         {
  80.                 return view;
  81.         }

  82.         /**
  83.          * 设置View的对象
  84.          */
  85.         public void setView(View view)
  86.         {
  87.                 this.view = view;
  88.         }

  89.         /**
  90.          * 获取View的宽度
  91.          * 
  92.          * @return View的宽度,double型
  93.          */
  94.         public double getViewWidth()
  95.         {
  96.                 return viewWidth;
  97.         }

  98.         /**
  99.          * 设置View的宽度,double型
  100.          * 
  101.          * @param viewWidth
  102.          */
  103.         public void setViewWidth(double viewWidth)
  104.         {
  105.                 this.viewWidth = viewWidth;
  106.         }

  107.         /**
  108.          * 获取View的高度
  109.          * 
  110.          * @return View的高度,double型
  111.          */
  112.         public double getViewHeight()
  113.         {
  114.                 return viewHeight;
  115.         }

  116.         /**
  117.          * 设置View的高度,double型
  118.          * 
  119.          * @param viewHeight
  120.          */
  121.         public void setViewHeight(double viewHeight)
  122.         {
  123.                 this.viewHeight = viewHeight;
  124.         }

  125.         /**
  126.          * 获取View距离左边的距离
  127.          * 
  128.          * @return View距离左边的距离,double型
  129.          */
  130.         public double getViewMarginLeft()
  131.         {
  132.                 return viewMarginLeft;
  133.         }

  134.         /**
  135.          * 设置View距离左边的距离,double型
  136.          * 
  137.          * @param viewMarginLeft
  138.          */
  139.         public void setViewMarginLeft(double viewMarginLeft)
  140.         {
  141.                 this.viewMarginLeft = viewMarginLeft;
  142.         }

  143.         /**
  144.          * 获取View距离上部的距离
  145.          * 
  146.          * @return View距离上部的距离,double型
  147.          */
  148.         public double getViewMarginTop()
  149.         {
  150.                 return viewMarginTop;
  151.         }

  152.         /**
  153.          * 设置View距离上部的距离,double型
  154.          * 
  155.          * @param viewMargdoubleop
  156.          */
  157.         public void setViewMarginTop(double viewMarginTop)
  158.         {
  159.                 this.viewMarginTop = viewMarginTop;
  160.         }
  161.         
  162.         /**
  163.          * 获取父类布局的类型
  164.          * @return parentLayoutType,int型
  165.          */
  166.         public int getParentLayoutType()
  167.         {
  168.                 return parentLayoutType;
  169.         }

  170.         /**
  171.          * 设置父类布局的类型
  172.          * @param parentLayoutType
  173.          */
  174.         public void setParentLayoutType(int parentLayoutType)
  175.         {
  176.                 this.parentLayoutType = parentLayoutType;
  177.         }

  178. }

第二步:创建一个计算方法:

  1. import java.util.List;

  2. import android.app.Activity;
  3. import android.content.Context;
  4. import android.util.DisplayMetrics;
  5. import android.view.View;
  6. import android.view.ViewGroup.LayoutParams;
  7. import android.widget.LinearLayout;
  8. import android.widget.RelativeLayout;

  9. /**
  10. * 分配率通配类
  11. * 
  12. * @author 
  13. * 
  14. */
  15. public class MyLayoutAdapter
  16. {
  17.         /**
  18.          * 基准分辨率的宽
  19.          */
  20.         public double STANDARD_SCREEN_WIDTH;

  21.         /**
  22.          * 基准分辨率的高
  23.          */
  24.         public double STANDARD_SCREEN_HEIGHT;

  25.         /**
  26.          * 系统当前的分辨率的宽
  27.          */
  28.         public double CURRENT_SCREEN_WIDTH;

  29.         /**
  30.          * 系统当前的分辨率的高
  31.          */
  32.         public double CURRENT_SCREEN_HEIGHT;

  33.         /**
  34.          * 基准屏幕密度
  35.          */
  36.         public static final double STANDARD_DENSITY = 160;

  37.         /**
  38.          * 当前屏幕密度
  39.          */
  40.         private double CURRENT_DENSITY;

  41.         /**
  42.          * 屏幕密度比例
  43.          */
  44.         private double DENSITY_RATIO;

  45.         /**
  46.          * 屏幕宽度比例
  47.          */
  48.         private double WIDTH_RATIO;

  49.         /**
  50.          * 屏幕高度比例
  51.          */
  52.         private double HEIGHT_RATIO;

  53.         /**
  54.          * 组件基准的宽度
  55.          */
  56.         private double viewStandardWidth;

  57.         /**
  58.          * 组件基准的高度
  59.          */
  60.         private double viewStandardHeight;

  61.         /**
  62.          * 组件基准的距离左边的距离
  63.          */
  64.         private double viewStandardMarginLeft;

  65.         /**
  66.          * 组件基准的距离顶部的距离
  67.          */
  68.         private double viewStandardMarginTop;

  69.         /**
  70.          * 组件当前的宽
  71.          */
  72.         private double viewCurrentWidth;

  73.         /**
  74.          * 组件当前的高
  75.          */
  76.         private double viewCurrentHeight;

  77.         /**
  78.          * 组件当前距离左边的距离
  79.          */
  80.         private double viewCurrentMarginLeft;

  81.         /**
  82.          * 组件当前距离顶部的距离
  83.          */
  84.         private double viewCurrentMarginTop;

  85.         /**
  86.          * UI组件的对象
  87.          */
  88.         private View view;

  89.         /**
  90.          * 此View的父类布局的类型
  91.          */
  92.         private int parentLayoutType;

  93.         /**
  94.          * 父类布局的类型为相对布局
  95.          */
  96.         private final int LAYOUT_TYPE_RELATiVELAYOUT = LayoutInformation.R;

  97.         /**
  98.          * 父类布局的类型为线性布局
  99.          */
  100.         private final int LAYOUT_TYPE_LINEARLAYOUT = LayoutInformation.L;

  101.         /**
  102.          * 布局属性为wrap_content
  103.          */
  104.         private final int LAYOUTPARAMS_WARP_CONTENT = LayoutParams.WRAP_CONTENT;

  105.         /**
  106.          * 布局属性为fill_parent
  107.          */
  108.         private final int LAYOUTPARAMS_FILL_PARENT = LayoutParams.FILL_PARENT;

  109.         private Context context;

  110.         /**
  111.          * 类对象实例化时,设置 基准屏幕宽度,高度
  112.          * 
  113.          * @param context
  114.          *            Context
  115.          * @param standardWidth
  116.          *            基准屏幕的宽
  117.          * @param standardHeight
  118.          *            基准屏幕的高
  119.          */
  120.         public MyLayoutAdapter(Context context, double standardWidth,
  121.                         double standardHeight)
  122.         {
  123.                 this.context = context;
  124.                 getScreenSize();
  125.                 STANDARD_SCREEN_HEIGHT = standardHeight;
  126.                 STANDARD_SCREEN_WIDTH = standardWidth;
  127.                 // 计算宽高比率
  128.                 WIDTH_RATIO = CURRENT_SCREEN_WIDTH / STANDARD_SCREEN_WIDTH;
  129.                 HEIGHT_RATIO = CURRENT_SCREEN_HEIGHT / STANDARD_SCREEN_HEIGHT;
  130.         }

  131.         /**
  132.          * 获取当前屏幕大小和密度
  133.          */
  134.         private void getScreenSize()
  135.         {
  136.                 DisplayMetrics displayMetrics = new DisplayMetrics();
  137.                 ((Activity) context).getWindowManager().getDefaultDisplay()
  138.                                 .getMetrics(displayMetrics);
  139.                 CURRENT_SCREEN_WIDTH = displayMetrics.widthPixels;
  140.                 CURRENT_SCREEN_HEIGHT = displayMetrics.heightPixels;
  141.                 CURRENT_DENSITY = displayMetrics.densityDpi;
  142.                 DENSITY_RATIO = STANDARD_DENSITY / CURRENT_DENSITY;
  143.         }

  144.         /**
  145.          * 进行通配
  146.          * 
  147.          * @param listdata
  148.          */
  149.         public void setViewLayout(List<LayoutInformation> listdata)
  150.         {

  151.                 for (int i = 0; i < listdata.size(); i++)
  152.                 {

  153.                         view = listdata.get(i).getView();

  154.                         viewStandardWidth = listdata.get(i).getViewWidth();

  155.                         viewStandardHeight = listdata.get(i).getViewHeight();

  156.                         viewStandardMarginLeft = listdata.get(i).getViewMarginLeft();

  157.                         viewStandardMarginTop = listdata.get(i).getViewMarginTop();

  158.                         setLayoutParams();

  159.                         viewCurrentMarginLeft = viewStandardMarginLeft * WIDTH_RATIO;

  160.                         viewCurrentMarginTop = viewStandardMarginTop * HEIGHT_RATIO;

  161.                         parentLayoutType = listdata.get(i).getParentLayoutType();
  162.                         setLayoutByParentLayoutType();
  163.                 }
  164.         }

  165.         /**
  166.          * 判断布局属性的值,设置布局的属性
  167.          */
  168.         private void setLayoutParams()
  169.         {
  170.                 // 如果基准的宽是wrap_content或者fill_parent则使用原值,否则进行计算得到通配后的值
  171.                 if (viewStandardWidth == LAYOUTPARAMS_WARP_CONTENT
  172.                                 || viewStandardWidth == LAYOUTPARAMS_FILL_PARENT)
  173.                 {
  174.                         viewCurrentWidth = viewStandardWidth;
  175.                 } else
  176.                 {
  177.                         viewCurrentWidth = viewStandardWidth * WIDTH_RATIO;
  178.                 }

  179.                 // 如果基准的宽是wrap_content或者fill_parent则使用原值,否则进行计算得到通配后的值
  180.                 if (viewStandardHeight == LAYOUTPARAMS_WARP_CONTENT
  181.                                 || viewStandardHeight == LAYOUTPARAMS_FILL_PARENT)
  182.                 {
  183.                         viewCurrentHeight = viewStandardHeight;
  184.                 } else
  185.                 {
  186.                         viewCurrentHeight = viewStandardHeight * HEIGHT_RATIO;
  187.                 }
  188.         }

  189.         /**
  190.          * 通过判断此View父类的布局类型,给此View设置布局
  191.          */
  192.         private void setLayoutByParentLayoutType()
  193.         {

  194.                 if (parentLayoutType == LAYOUT_TYPE_RELATiVELAYOUT)
  195.                 {

  196.                         RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
  197.                                         (int) viewCurrentWidth, (int) viewCurrentHeight);

  198.                         params.setMargins((int) viewCurrentMarginLeft,
  199.                                         (int) viewCurrentMarginTop, 0, 0);

  200.                         view.setLayoutParams(params);

  201.                 } else if (parentLayoutType == LAYOUT_TYPE_LINEARLAYOUT)
  202.                 {

  203.                         LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
  204.                                         (int) viewCurrentWidth, (int) viewCurrentHeight);
  205.                         params.setMargins((int) viewCurrentMarginLeft,
  206.                                         (int) viewCurrentMarginTop, 0, 0);
  207.                         view.setLayoutParams(params);
  208.                 }
  209.         }

  210.         /**
  211.          * 设置字体大小
  212.          * 
  213.          * @param standardSize
  214.          *            原始大小
  215.          * @return int
  216.          */
  217.         public int setTextSize(int standardSize)
  218.         {
  219.                 int currentSize;

  220.                 currentSize = (int) (standardSize * WIDTH_RATIO * DENSITY_RATIO);

  221.                 return currentSize;
  222.         }
  223. }
复制代码第三步,写一个接口:

  1. public interface InitAllView{
  2.         /**
  3.          * 初始化控件的大小
  4.          */
  5.         public void initAllView();

  6. }
复制代码第四步:代码控制:

  1. /**
  2.          * 通配方法
  3.          */
  4.         private void initWildcard() {
  5.                 myLayout = new MyLayoutAdapter(this, 320, 480);
  6.                 listInfo = new ArrayList<LayoutInformation>();
  7.                 listInfo.add(new LayoutInformation(mBtn1, LayoutParams.WRAP_CONTENT,
  8.                                 LayoutParams.WRAP_CONTENT, 0, 0, LayoutInformation.R));
  9.                 listInfo.add(new LayoutInformation(mNowRegisterBtn, 80, 27.3, 14.7, 0,
  10.                                 LayoutInformation.R));
  11.                 listInfo.add(new LayoutInformation(mNextRegisterBtn, 80, 27.3, 14.7, 0,
  12.                                 LayoutInformation.R));

  13.                 // listInfo.add(new LayoutInformation(mCheckBtn, 17.3,17.3, 14.7, 0,
  14.                 // LayoutInformation.L));
  15.                 mBtn1.setTextSize(myLayout.setTextSize(12));
  16.                 mNowRegisterBtn.setTextSize(myLayout.setTextSize(12));
  17.                 mNextRegisterBtn.setTextSize(myLayout.setTextSize(12));
  18.                 myLayout.setViewLayout(listInfo);
  19.         }
复制代码效果对比如下:
小的图片是通过适应过的,大的图片是没有做适配的。可以看得出来他们的差异很明显。如果各位大婶有什么新的方法,希望多多推荐,小弟也可以多学习几种。




效果图.jpg (6.01 KB, 下载次数: 11)

效果对比

分辨率适配的步骤


  1. package com.zte.layout.adapter;

  2. import android.view.View;

  3. /**
  4. * 存储View信息的JavaBean类
  5. * 
  6. * @author 
  7. * 
  8. */
  9. public class LayoutInformation
  10. {
  11.         /**
  12.          * View的对象
  13.          */
  14.         private View view;

  15.         /**
  16.          * View的宽度
  17.          */
  18.         private double viewWidth;

  19.         /**
  20.          * View的高度
  21.          */
  22.         private double viewHeight;

  23.         /**
  24.          * View距左边的距离,即marginLeft
  25.          */
  26.         private double viewMarginLeft;

  27.         /**
  28.          * View距顶部的距离,即MarginTop;
  29.          */
  30.         private double viewMarginTop;
  31.         
  32.         /**
  33.          * 父类布局的类型为相对布局
  34.          */
  35.         public static int R=-1;
  36.         
  37.         /**
  38.          * 父类布局的类型为线性布局
  39.          */
  40.         public static int L=-2;
  41.         
  42.         /**
  43.          * 此View的父类布局的类型
  44.          */
  45.         private int parentLayoutType;

  46.         /**
  47.          * 存储View信息的JavaBean类
  48.          * 
  49.          * @param view
  50.          *            View的对象
  51.          * @param viewWidth
  52.          *            View的宽
  53.          * @param viewHeight
  54.          *            View的高
  55.          * @param viewMarginLeft
  56.          *            View距左边的距离
  57.          * @param viewMargdoubleop
  58.          *            View距上部的距离
  59.          * @param parentLayoutType
  60.          *            父类布局的类型,LayoutInformation.R
  61.          *            (表示相对布局)或者LayoutInformation.L(表示线性布局)
  62.          */
  63.         public LayoutInformation(View view, double viewWidth, double viewHeight,
  64.                         double viewMarginLeft, double viewMarginTop, int parentLayoutType)
  65.         {

  66.                 this.view = view;
  67.                 this.viewWidth = viewWidth;
  68.                 this.viewHeight = viewHeight;
  69.                 this.viewMarginLeft = viewMarginLeft;
  70.                 this.viewMarginTop = viewMarginTop;
  71.                 this.parentLayoutType=parentLayoutType;
  72.         }

  73.         /**
  74.          * 获取View的对象
  75.          * 
  76.          * [url=home.php?mod=space&uid=7300]@return[/url] View对象
  77.          */
  78.         public View getView()
  79.         {
  80.                 return view;
  81.         }

  82.         /**
  83.          * 设置View的对象
  84.          */
  85.         public void setView(View view)
  86.         {
  87.                 this.view = view;
  88.         }

  89.         /**
  90.          * 获取View的宽度
  91.          * 
  92.          * @return View的宽度,double型
  93.          */
  94.         public double getViewWidth()
  95.         {
  96.                 return viewWidth;
  97.         }

  98.         /**
  99.          * 设置View的宽度,double型
  100.          * 
  101.          * @param viewWidth
  102.          */
  103.         public void setViewWidth(double viewWidth)
  104.         {
  105.                 this.viewWidth = viewWidth;
  106.         }

  107.         /**
  108.          * 获取View的高度
  109.          * 
  110.          * @return View的高度,double型
  111.          */
  112.         public double getViewHeight()
  113.         {
  114.                 return viewHeight;
  115.         }

  116.         /**
  117.          * 设置View的高度,double型
  118.          * 
  119.          * @param viewHeight
  120.          */
  121.         public void setViewHeight(double viewHeight)
  122.         {
  123.                 this.viewHeight = viewHeight;
  124.         }

  125.         /**
  126.          * 获取View距离左边的距离
  127.          * 
  128.          * @return View距离左边的距离,double型
  129.          */
  130.         public double getViewMarginLeft()
  131.         {
  132.                 return viewMarginLeft;
  133.         }

  134.         /**
  135.          * 设置View距离左边的距离,double型
  136.          * 
  137.          * @param viewMarginLeft
  138.          */
  139.         public void setViewMarginLeft(double viewMarginLeft)
  140.         {
  141.                 this.viewMarginLeft = viewMarginLeft;
  142.         }

  143.         /**
  144.          * 获取View距离上部的距离
  145.          * 
  146.          * @return View距离上部的距离,double型
  147.          */
  148.         public double getViewMarginTop()
  149.         {
  150.                 return viewMarginTop;
  151.         }

  152.         /**
  153.          * 设置View距离上部的距离,double型
  154.          * 
  155.          * @param viewMargdoubleop
  156.          */
  157.         public void setViewMarginTop(double viewMarginTop)
  158.         {
  159.                 this.viewMarginTop = viewMarginTop;
  160.         }
  161.         
  162.         /**
  163.          * 获取父类布局的类型
  164.          * @return parentLayoutType,int型
  165.          */
  166.         public int getParentLayoutType()
  167.         {
  168.                 return parentLayoutType;
  169.         }

  170.         /**
  171.          * 设置父类布局的类型
  172.          * @param parentLayoutType
  173.          */
  174.         public void setParentLayoutType(int parentLayoutType)
  175.         {
  176.                 this.parentLayoutType = parentLayoutType;
  177.         }

  178. }