dependencies {
compile 'com.android.support:percent:22.2.0'
}

支持布局

PercentRelativeLayout

<android.support.percent.PercentRelativeLayout    xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"> <View
android:id="@+id/top_left"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_alignParentTop="true"
android:background="#ff44aacc"
app:layout_heightPercent="20%"
app:layout_widthPercent="70%" /> <View
android:id="@+id/top_right"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/top_left"
android:background="#ffe40000"
app:layout_heightPercent="20%"
app:layout_widthPercent="30%" /> <View
android:id="@+id/bottom"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_below="@+id/top_left"
android:background="#ff00ff22"
app:layout_heightPercent="80%" />
</android.support.percent.PercentRelativeLayout>

Android 终于官方支持按百分比来设置控件的宽高了的更多相关文章

  1. android PercentRelativeLayout 支持百分比来设置控件的宽高

    Android 最终官方支持按百分比来设置控件的宽高了. 我们先来看看效果:       看一下布局: PercentRelativeLayout <android.support.percen ...

  2. Android 如何在Java代码中手动设置控件的marginleft

    1.定义LayoutParams LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.La ...

  3. Android在onCreate中获取控件的宽高

    在某些需求下,我们需要在onCreate的时候就获取到控件的宽高,但是如果直接用view.getWidth()或view.getHeight()会得到0.这是因为在onCreate执行的时候,控件还没 ...

  4. Android开发技巧——定制仿微信图片裁剪控件

    拍照--裁剪,或者是选择图片--裁剪,是我们设置头像或上传图片时经常需要的一组操作.上篇讲了Camera的使用,这篇讲一下我对图片裁剪的实现. 背景 下面的需求都来自产品. 裁剪图片要像微信那样,拖动 ...

  5. Android自定义View(三、深入解析控件测量onMeasure)

    转载请标明出处: http://blog.csdn.net/xmxkf/article/details/51490283 本文出自:[openXu的博客] 目录: onMeasure什么时候会被调用 ...

  6. Android初级教程_获取Android控件的宽和高

    转载:http://blog.csdn.net/johnny901114/article/details/7839512 我们都知道在onCreate()里面获取控件的高度是0,这是为什么呢?我们来看 ...

  7. 我的Android进阶之旅------>如何获取Android控件的宽和高

    本文转载于:http://blog.csdn.net/johnny901114/article/details/7839512 我们都知道在onCreate()里面获取控件的高度是0,这是为什么呢?我 ...

  8. 【转】获取Android控件的宽和高

    我们都知道在onCreate()里面获取控件的高度是0,这是为什么呢?我们来看一下示例: 首先我们自己写一个控件,这个控件非常简单: public class MyImageView extends ...

  9. android屏幕适配的全攻略3-动态获取手机屏幕宽高及动态设置控件宽高

    1.获取手机屏幕宽高: DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetr ...

随机推荐

  1. 仿苹果导航菜单js问题

    通过鼠标与不同图片的间距比对图片做相应的放大缩小. <div id="box"> <img src="images/1.png" class= ...

  2. YY前端课1

    1. HTML页面主要由声明.头部.主体三部分构成. 2. 头部及其meta标签,以及主体的title标签很重要,对SEO.搜索优化等很重要. 3. 常用的charset编码格式有2种,一种是utf- ...

  3. 一个靠谱的国外maven镜像地址

    <mirror> <id>ui</id> <mirrorOf>central</mirrorOf> <name>Human Re ...

  4. Java中sql语句的引号问题

    1..sql语句 在数据库中,当我们查询语句时,会使用类似的语句: Select * from userinfo where userid='1' or 1; Select * from userin ...

  5. android .9图的作用

    参考:http://www.cnblogs.com/lianghui66/archive/2013/01/08/2850581.html .9图的介绍 1.这种格式的图片是Android平台上一种被拉 ...

  6. vs启动调试很慢的解决办法

    1.关闭所有 Visual Studio 2010 实例. 2.单击“开始”,选择“运行...”. 3.键入“devenv.exe /resetuserdata”. 此命令会运行几分钟时间,与此同时, ...

  7. virtual_login

    from selenium import webdriverimport timedriver = webdriver.Chrome()driver.set_window_position(30, 4 ...

  8. C#之委托

    委托是C#中非常重要的一个概念,并在C#中得到了丰富的应用,如事件,线程等.那什么是委托呢?具体来说,委托是一种引用方法的类型.一旦为委托分配了方法,委托将与该方法具有完全相同的行为.委托方法的使用可 ...

  9. Linux 内核常见宏定义

    我们在阅读Linux内核是,常见到这些宏 __init, __initdata, __initfunc(), asmlinkage, ENTRY(), FASTCALL()等等.它们定义在 /incl ...

  10. lucene中Field.Index,Field.Store详解

    lucene在doc.add(new Field("content",curArt.getContent(),Field.Store.NO,Field.Index.TOKENIZE ...