我有如下一个编辑文本布局,我想知道,有没有什么办法可以提供不同尺寸是不同的硬件依赖于它的屏幕尺寸是多少?对于小于4英寸显示屏幕,我想给下面的布局
<的EditText
机器人:ID =@ + ID /条目
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:背景=@机器人:可绘制/ editbox_background
机器人:文字颜色=#800080
机器人:文本=
机器人:提示=无操作precednce尚未
机器人:cursorVisible =假
机器人:TEXTSIZE =40dip
/>
,然后别人
<的EditText
机器人:ID =@ + ID /条目
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:背景=@机器人:可绘制/ editbox_background
机器人:文字颜色=#800080
机器人:文本=
机器人:提示=无操作precednce尚未
机器人:cursorVisible =假
机器人:TEXTSIZE =30dip
/>
解决方案
为
在创建/ RES文件夹布局
布局小
布局正常
布局大
布局XLARGE
然后为每个布局的布局文件,Android将选择合适的一个在运行时。 这样你就可以改变整个布局,每个屏幕尺寸。
如果你真的只想要设置的大小,你可以创建这个文件夹
值
值小
值正常
价值观大
价值观XLARGE
然后把dimen.xml在每个这样的文件夹是这样的:
< XML版本=1.0编码=UTF-8>
<资源>
<扪名=textSizeLarge> 22dp< /扪>
< /资源>
只是改变在每个XML文件中的值(22dp)。
然后替换你的价值
安卓TEXTSIZE =@扪/ textSizeXtraSmall
很好documantation: http://developer.android.com/guide/practices/screens_support.html
I have a edit text layout as below and I want to know, is there any way to provide different size for it for different hardware depending on its screen size? For screens below 4 inches I want to give the below layout
<EditText
android:id="@+id/entry"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:drawable/editbox_background"
android:textColor="#800080"
android:text=""
android:hint=" No Operator Precednce yet"
android:cursorVisible="false"
android:textSize="40dip"
/>
and then for others
<EditText
android:id="@+id/entry"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:drawable/editbox_background"
android:textColor="#800080"
android:text=""
android:hint=" No Operator Precednce yet"
android:cursorVisible="false"
android:textSize="30dip"
/>
解决方案
Create folders in /res for
layout
layout-small
layout-normal
layout-large
layout-xlarge
then create a layout file for each layout, android will choose the right one on runtime. so you can change the complete layout for each screensize.
If you really only want to set the size, you can create this folders
values
values-small
values-normal
values-large
values-xlarge
then put a dimen.xml in each of this folders like this :
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="textSizeLarge">22dp</dimen>
</resources>
just change the value (22dp) in each xml file.
then replace your value with
android:textSize="@dimen/textSizeXtraSmall"
Very good documantation : http://developer.android.com/guide/practices/screens_support.html