首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

分辨率适配的步骤

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

分辨率适配的方法

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

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



  1. package com.zte.layout.adapter;

  2. import android.view.View;

  3. /**
  4. * 存储View信息的JavaBean类

  5. * @author 

  6. */
  7. public class LayoutInformation
  8. {
  9.         /**
  10.          * View的对象
  11.          */
  12.         private View view;

  13.         /**
  14.          * View的宽度
  15.          */
  16.         private double viewWidth;

  17.         /**
  18.          * View的高度
  19.          */
  20.         private double viewHeight;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  2. import android.view.View;

  3. /**
  4. * 存储View信息的JavaBean类

  5. * @author 

  6. */
  7. public class LayoutInformation
  8. {
  9.         /**
  10.          * View的对象
  11.          */
  12.         private View view;

  13.         /**
  14.          * View的宽度
  15.          */
  16.         private double viewWidth;

  17.         /**
  18.          * View的高度
  19.          */
  20.         private double viewHeight;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  176. }

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

  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. * @author 

  12. */
  13. public class MyLayoutAdapter
  14. {
  15.         /**
  16.          * 基准分辨率的宽
  17.          */
  18.         public double STANDARD_SCREEN_WIDTH;

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

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

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

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

  35.         /**
  36.          * 当前屏幕密度
  37.          */
  38.         private double CURRENT_DENSITY;

  39.         /**
  40.          * 屏幕密度比例
  41.          */
  42.         private double DENSITY_RATIO;

  43.         /**
  44.          * 屏幕宽度比例
  45.          */
  46.         private double WIDTH_RATIO;

  47.         /**
  48.          * 屏幕高度比例
  49.          */
  50.         private double HEIGHT_RATIO;

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

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

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

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

  67.         /**
  68.          * 组件当前的宽
  69.          */
  70.         private double viewCurrentWidth;

  71.         /**
  72.          * 组件当前的高
  73.          */
  74.         private double viewCurrentHeight;

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

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

  83.         /**
  84.          * UI组件的对象
  85.          */
  86.         private View view;

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

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

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

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

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

  107.         private Context context;

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

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

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

  149.                 for (int i = 0; i < listdata.size(); i++)
  150.                 {

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

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

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

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

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

  156.                         setLayoutParams();

  157.                         viewCurrentMarginLeft = viewStandardMarginLeft * WIDTH_RATIO;

  158.                         viewCurrentMarginTop = viewStandardMarginTop * HEIGHT_RATIO;

  159.                         parentLayoutType = listdata.get(i).getParentLayoutType();
  160.                         setLayoutByParentLayoutType();
  161.                 }
  162.         }

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

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

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

  192.                 if (parentLayoutType == LAYOUT_TYPE_RELATiVELAYOUT)
  193.                 {

  194.                         RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
  195.                                         (int) viewCurrentWidth, (int) viewCurrentHeight);

  196.                         params.setMargins((int) viewCurrentMarginLeft,
  197.                                         (int) viewCurrentMarginTop, 0, 0);

  198.                         view.setLayoutParams(params);

  199.                 } else if (parentLayoutType == LAYOUT_TYPE_LINEARLAYOUT)
  200.                 {

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

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

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

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

  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. * @author 

  6. */
  7. public class LayoutInformation
  8. {
  9.         /**
  10.          * View的对象
  11.          */
  12.         private View view;

  13.         /**
  14.          * View的宽度
  15.          */
  16.         private double viewWidth;

  17.         /**
  18.          * View的高度
  19.          */
  20.         private double viewHeight;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  176. }

热点排行