在Android的百分比测量屏幕 [英] Android Measure Screen in percentage

查看:161
本文介绍了在Android的百分比测量屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我没有在Android布局这么多的研究,我发现这么多的答案,但没有找到任何答案,告诉我,我怎么可以测量屏幕实际比例
刚发现表格布局与重量比的线性,最好的一次是体重直线,但很难再管理百分比!

I did so many research on Android layouts i found so many answers but not found any answer which tells me how can i measure screen in actual percentage just found table layouts linear with weight, best one was linear with weight but difficult to manage percentage again!!!

推荐答案

百分比是指比出100

线性布局,重量不难以管理技术上可以在这样百分比管理线性布局,

Linear layout with weight is not difficult to manage you can technically manage linear layout in percentage like this,

让假设你的主要布局的android:weightSum =100
这意味着你的整个屏幕大小为100%,现在你可以指定每一个布局宽度

Let suppose your main layout android:weightSum="100" that mean your total screen size is 100% now you can specify every layouts width

示例

<?xml version="1.0" encoding="utf-8"?>  
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<LinearLayout
    android:id="@+id/layout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:weightSum="100" >

    <TextView
        android:id="@+id/one"
        android:layout_width="0dp"
        android:layout_height="fill_parent"
        android:layout_weight="12"
        android:background="#FF9933"
        android:text="No:" />

    <TextView
        android:id="@+id/two"
        android:layout_width="0dp"
        android:layout_height="fill_parent"
        android:layout_weight="63"
        android:background="#CC33CC"
        android:text="Desc" />

    <TextView
        android:id="@+id/three"
        android:layout_width="0dp"
        android:layout_height="fill_parent"
        android:layout_weight="25"
        android:background="#FF9999"
        android:text="Total" />
</LinearLayout>

根据百分比第一列是12%,第二个是63%和最后一个是25%

according to percentage first column is 12% second is 63% and last one is 25%

这篇关于在Android的百分比测量屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆