2012-02-03 38 views
0

我有一個線性佈局的textview和edittext。如果按照我已經看到的每個使用weight來設置寬度的例子,我都可以看到,但是根本沒有任何視圖出現。Android重量不工作

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
<TextView 
    android:id="@+id/custLabel" 
    android:layout_height="wrap_content" 
    android:layout_weight=".35" 
    android:layout_width="0dip" 
    android:text="Name"/> 
<EditText 
    android:id="@+id/customer" 
    android:layout_height="wrap_content" 
    android:layout_weight=".65" 
    android:layout_width="0dip"/> 
</LinearLayout> 
+0

我在visual studio中使用單聲道機器人。直接調試到設備。 – jmease 2012-02-03 21:40:42

+0

您的'LinearLayout'具有垂直方向。爲你的'TextView'和'EditText'設置''layout_width'爲'wrap_content''和'layout_height'爲'0dp'。你這樣做是錯誤的。 – Squonk 2012-02-03 21:42:50

+0

@MisterSquonk這是我第一次輸入禁食比一些大師:-) – Gangnus 2012-02-03 21:45:24

回答

2

更改佈局的方向。你有它垂直,把東西放在那裏,加重寬度!

+0

三天前,由於LinearLayout方向錯誤,我浪費了3個小時:-) – Gangnus 2012-02-03 21:42:20

+0

這樣做。將在4分鐘內接受。謝謝! – jmease 2012-02-03 21:47:28