Android输出比例,如何使Android布局与屏幕大小和方向成比例

这是我第一篇文章。我刚刚学习了Android编程并遇到了这个问题。我已经搜索了一下,发现了一些解决方案,但我无法让我的代码工作。所以我想知道我的代码或实现的哪个部分是错误的。如何使Android布局与屏幕大小和方向成比例

所以,问题是我希望做一个布局,将停留在不同的屏幕尺寸和方向相同的比例。这里是我的代码:“你至少需要10声誉发表图片”

activity_main.xml中

xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:baselineAligned="false"

android:orientation="vertical">

android:layout_width="fill_parent"

android:layout_height="150dp" >

android:layout_weight="1"

android:layout_width="0dp"

android:layout_height="fill_parent"

android:gravity="left"

android:id="@+id/textView1"/>

android:layout_weight="1"

android:layout_width="0dp"

android:layout_height="fill_parent"

android:gravity="right"

android:id="@+id/textView2"/>

android:layout_weight="1"

android:layout_width="fill_parent"

android:layout_height="fill_parent" >

android:layout_weight="1"

android:layout_width="0dp"

android:layout_height="fill_parent"

android:id="@+id/textView3"/>

android:layout_weight="1"

android:layout_width="fill_parent"

android:layout_height="fill_parent" >

android:layout_weight="1"

android:layout_width="0dp"

android:layout_height="fill_parent"

android:gravity="left"

android:id="@+id/textView4"/>

android:layout_weight="1"

android:layout_width="0dp"

android:layout_height="fill_parent"

android:gravity="center"

android:id="@+id/textView5"/>

android:layout_weight="1"

android:layout_width="0dp"

android:layout_height="fill_parent"

android:gravity="right"

android:id="@+id/textView6"/>

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:id="@+id/seekBar"

android:max="255"/>

我不能在此刻帖子截图,因为它说

所以,我想由3个部分垂直分割屏幕,并通过3水平2水平和底部划分顶部且不论屏幕尺寸,分辨率和方向都保持其比例。

唯一没有工作的部分是顶部的块,在我将其设置为android:layout_height="150dp"的代码上,因为如果将这些设置设置为android:layout_height="fill_parent",那么布局会以某种方式中断。但是,如果我改变方向,这不会使布局成比例。任何帮助将不胜感激。

谢谢。

2015-05-27

Wellsen

+0

您应该阅读'LinearLayout'&'weight'! –

+0

如果你想150dp的布局比你为什么要用其他布局的重量概念? –

+0

嗨,非常感谢你的提示。我现在发现了这个问题。我将它们设置为'android:layout_height =“fill_parent”',但忘记设置'weight'。对不起,初学者的错误。 –

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值