2012-04-19 72 views
0

我正在顯示想要生成的所需佈局的圖像我是新來的Android開發我也列出了我的XML爲此...在其中我能夠修復TextView和WebView但我不是能夠修復我左邊的按鈕,任何人都可以向我建議我必須做的必要的添加以及我的XML文件中的位置。如何在Android中修復XML佈局?

enter image description here

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 

    > 




    <TextView 
     android:id="@+id/txtItem1" 
     android:text="ITEM" 
     android:layout_width="fill_parent" 
     android:layout_height="50dip" 
     android:textColor="#009966" 
     android:background="@drawable/txtbackground" 

     /> 

    <!-- WebView --> 
    <LinearLayout android:id="@+id/thumbnail" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:padding="3dip" 
     android:layout_alignParentLeft="true" 
     android:background="@drawable/image_bg" 
     android:layout_marginTop="50dip" 
     > 

     <WebView 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/webkit" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 


     /> 
    </LinearLayout>  

</RelativeLayout> 

在此先感謝。

+0

嗨,讓我爲您安排代碼。 – 2012-04-19 12:01:40

回答

2

只需更換下面的代碼將正常工作。

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

    > 
<RelativeLayout 
    android:layout_height="wrap_content" 
    android:layout_width="wrap_content" 
    android:id="@+id/header" 
    > 
    <TextView 
     android:id="@+id/txtItem1" 
     android:text="ITEM" 
     android:layout_alignParentRight="true" 
     android:layout_width="wrap_content" 
     android:layout_height="50dip" 
     android:textColor="#009966" 

     /> 
<Button 
    android:layout_alignParentLeft="true" 
    android:layout_height="wrap_content" 
    android:layout_width="wrap_content" 
    android:text="Button" 
    /> 



    </RelativeLayout> 

    <!-- WebView --> 
    <LinearLayout android:id="@+id/thumbnail" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:padding="3dip" 
     android:layout_below="@+id/header" 
     android:layout_marginTop="50dip" 
     > 

     <WebView 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/webkit" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_alignParentLeft="true" 


     /> 
    </LinearLayout>  

</RelativeLayout> 
0

沒有得到太多的深入細節,你的佈局應該是這樣的:

<LinearLayout orientation="horizontal"> 
    <Button /> 
    <TextView /> 
</LinearLayout> 
<WebView /> 
1

只需複製並在你的文件粘貼。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:orientation="vertical" > 

<LinearLayout 
    android:id="@+id/linearLayout1" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" > 

    <Button 
     android:id="@+id/button1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Button" /> 

    <TextView 
     android:id="@+id/txtItem1" 
     android:layout_width="fill_parent" 
     android:layout_height="50dip" 
     android:background="@drawable/txtbackground" 
     android:text="ITEM" 
     android:textColor="#009966" /> 
</LinearLayout> 

<!-- WebView --> 

<LinearLayout 
    android:id="@+id/thumbnail" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentLeft="true" 
    android:layout_marginTop="50dip" 
    android:background="@drawable/image_bg" 
    android:padding="3dip" > 

    <WebView 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/webkit" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" /> 
</LinearLayout> 

0

複製並粘貼此代碼在XML文件中

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 

> 

<Button 
    android:id="@+id/button1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentTop="true" 
    android:text="Button" /> 

<TextView 
    android:id="@+id/textView1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 

    android:layout_marginLeft="39dp" 
    android:layout_toRightOf="@+id/button1" 
    android:text="TextView" /> 
<WebView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/webkit" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_alignParentLeft="true" 
    android:layout_below="@+id/button1" 


    />