2011-12-27 123 views
0

对于xml行: android:layout_width="fill_parent",是否有像fill_parent/2这样的常量值?我希望我的对象只填充屏幕的一半,而不是全部。在xml中创建一个宽度和高度为屏幕一半的对象

+0

可能会使用layout_weight属性 – 2011-12-27 06:05:28

+0

给出您的xml布局文件。 – 2011-12-27 06:41:00

+0

<?xml version =“1.0”encoding =“utf-8”?> Someonation 2011-12-27 06:43:28

回答

2

可以为此目的使用线性布局的“权重”。例如如果要在两个控件之间划分可用空间:

<LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 
     <EditText 
      android:layout_height="wrap_content" 
      android:layout_width="0dp" 
      android:layout_weight="1.0"/> 
     <EditText 
      android:layout_height="wrap_content" 
      android:layout_width="0dp" 
      android:layout_weight="1.0"/> 
</LinearLayout> 
1

按比例尺寸使用Layout_weight LinearLayout的方法。 为你的情况

<Linearlayout weight_sum=2> 
    <yourView layout_weight=1 /> 
</Linearlayout> 

//须藤语法

+0

我不使用布局,我的代码是用于列表视图,并且我是通过android.com教程说只使用TextView创建一个xml文件 – Someonation 2011-12-27 06:11:53

+0

hmmmmmmm ........似乎你正在使用arrayAdapter而不是自定义的适配器。不用担心,只需通过R.layout.name和R.id.textviewid即可。为更多的帮助粘贴代码snippate – 2011-12-27 06:51:17

+0

好的,所以我切换R.layout.name与R.layout.TextViewID ...然后什么?...如果我想告诉你我的代码,我该怎么做?我无法从格式帮助中了解如何制作块来发布代码 – Someonation 2011-12-27 06:59:54

相关问题