当前位置: 首页 > news >正文

企业网站数防泄露怎么做《新闻联播》今天

企业网站数防泄露怎么做,《新闻联播》今天,北京中小企业网站建设,开发商是不是建设单位最近在写项目的时候经常要进行屏幕适配,很多时候都会遇到layout_weight属性,很多人也不太清楚这个属性是怎么去使用,包括之前我自己都有点用不好,经常会弄混淆,那么今天就来稍微整理下。 layout_weight属性的作用&…

最近在写项目的时候经常要进行屏幕适配,很多时候都会遇到layout_weight属性,很多人也不太清楚这个属性是怎么去使用,包括之前我自己都有点用不好,经常会弄混淆,那么今天就来稍微整理下。

      layout_weight属性的作用:主要是用来分配剩余空间的一个属性,可以设置它的权重。特别注意一点就是,这个属性在Linearlayout下设置才有效。

     下面我们来看看以下几种情况:

第一种情况:我们将LinearLayout的布局设置为垂直排列,并且Button的高度都设置为wrap_content,权重分别为1,2,3。然后我们看看下面的效果图

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical" ><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_weight="1"android:text="button1" /><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_weight="2"android:text="button2" ></Button><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_weight="3"android:text="button3" ></Button></LinearLayout>
     

从上图可以看出,是将整个屏幕的高度分成了6份,然后根据权重的大小来分配剩余的空间。button1是占1/6,button2是占1/3,button3是占1/2。

第二种情况:依然设置为LinearLayout的布局设置为垂直排列,但是我将Button的高度都设置为match_parent,各个Button所占的权重依然是1,2,3;接着看下面的效果图:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical" ><Buttonandroid:layout_width="wrap_content"android:layout_height="match_parent"android:layout_weight="1"android:text="button1" /><Buttonandroid:layout_width="wrap_content"android:layout_height="match_parent"android:layout_weight="2"android:text="button2" ></Button><Buttonandroid:layout_width="wrap_content"android:layout_height="match_parent"android:layout_weight="3"android:text="button3" ></Button></LinearLayout>

咦,大家一看肯定很迷糊,这个Button3跑哪去了呢?当设置了layout_weight这个属性之后,那么这个View的高度就等于原来的高度加上剩余空间所占的比例。那么剩余空间怎么求呢?下面我来告诉大家,对于这里来说,求的就是剩余的高度:首先我们假设屏幕的高度是height,因为每个View都是设置的match_parent,所以每个View的高度都是height,那么这里有三个Button,也就是三个View,剩余的高度就是用屏幕的高度-3*view的高度,height-3*height=-2height,这样我们就把剩余的高度求出来了,下面我们分别算出每个Button的高度:button1 = height+(-2*height)*1/6 = 2/3height;button2的高度为:button2 = height + (-2*height)*1/3 = 1/3height;button3的高度为:button3 = height  + (-2*height)*1/2 = 0;所以根据计算的结果,屏幕的高度分配就是2:1:0,所以button3就没有空间可以显示了。


第三种情况:我们将LinearLayout的布局设置为水平排列,并且Button的宽度都设置为wrap_content,权重分别为1,2。然后我们看看下面的效果图:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="horizontal" ><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_weight="1"android:text="button1" /><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_weight="2"android:text="button2" ></Button></LinearLayout>

从上图可以看出,是将整个屏幕的高度分成了3份,然后根据权重的大小来分配剩余的空间。button1是占1/3,button2是占2/3。

第四种情况:依然设置为LinearLayout的布局设置为水平排列,但是我将Button的宽度都设置为match_parent,各个Button所占的权重依然是1,2,3;接着看下面的效果图:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="horizontal" ><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_weight="1"android:text="button1" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_weight="2"android:text="button2" ></Button><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_weight="3"android:text="button3" ></Button></LinearLayout>

button3依然没有显示出来,这里就不分析了,就是把上面的高度改为宽度,然后就自己去算吧,原理都是一样的。

最后来稍稍总结一下吧:首先 layout_weight这个属性是在LinearLayout中设置才有效,当LinearLayout的方向为垂直排列的时候,我们layout_weight是针对高度来进行权重的分配;LinearLayout的方向为水平排列的时候,我们layout_weight是针对宽度来进行权重的分配。


http://www.hkea.cn/news/573831/

相关文章:

  • 贵阳网站建设哪家便宜微商软文范例大全100
  • 怎么在微信上做网站竞价交易
  • wordpress优化版4.7.4网站seo设计
  • 网上课程网站精准客户数据采集软件
  • 专业网站建设报价外呼系统电销
  • 网站建设公司价格差别seo还有哪些方面的优化
  • 哪家公司建造了迪士尼乐园关键词优化推广排名多少钱
  • 做教育的网站有哪些内容吗湖南网站营销推广
  • wordpress 跳过ftp搜索引擎排名优化方案
  • 360做的网站北京营销推广公司
  • 我国政府网站建设的趋势宁波seo公司排名榜
  • 高端网站建设,恩愉科技专业的seo搜索引擎优化培训
  • 跨境网站开发公司网站seo思路
  • 冠县网站建设活动推广方案
  • 鲜花培训网站建设网站推广要点
  • 情趣内衣怎么做网站如何制作网页
  • 网站交互技术百度推广登陆后台
  • 网站的推广和宣传方式各行业关键词
  • 腾讯云服务器网站建设淘宝推广哪种方式最好
  • 大专网站建设论文找个免费的网站
  • 移动端网站开发流程图seopeix
  • 购物网站制作免费太原seo招聘
  • 怎么建设食品网站济南seo外包公司
  • 建设网站有哪些seopeix
  • 桂林市工程建设项目招标网站莆田百度快照优化
  • 金华网站建设大型网页建设农产品网络营销
  • wordpress free cdn长沙百度快速优化
  • 网页界面设计首页seo快速优化软件网站
  • 和凡科网类似的网站四川省人民政府
  • 北辰网站建设如何推广引流