2010-04-12 24 views
1

我嘗試了多個解決方案,但似乎沒有工作。佈局:Android:如何使用可滾動文本視圖進行當前佈局?

-------------------- 
|btn1| txt1 |btn2| 
-------------------- 
|     | 
|     | 
|     | 
|  txtview1  | 
|     | 
|     | 
|     | 
-------------------- 

BTN1 - 頂部左對齊 - 減少TXT1
BTN2 - 右上對齊 - 增加TXT1
TXT1 - 頂部居中對齊 - 用代碼
textview1輸入的文本/號碼 - 客戶端垂直滾動條排列如果需要的話 - 文本與代碼中輸入

回答

3

試試這個:

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

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

    <TextView 
     android:id="@+id/txt1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:text="txt1"/> 

    <Button 
     android:id="@+id/btn2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:text="btn2"/> 

    <ScrollView 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_below="@id/btn1"> 

     <TextView 
      android:id="@+id/txt2" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:text="txt2"/> 

    </ScrollView> 

</RelativeLayout> 
+0

非常好,但TXT2也超過BTN1,TXT2和BTN2。它應該在他們之下。 – Solata 2010-04-12 12:55:37

+0

ups,忽略android:layout_below =「@ id/btn1」。 – Solata 2010-04-12 14:11:11

1

你也應該對齊秒ond按鈕向右。
你的版本放在第二個按鈕在第一個...

例子:現在

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

    <Button android:id="@+id/button1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="back"/> 
    <TextView android:id="@+id/txt1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerHorizontal="true" 
       android:text="txt1"/> 
    <Button android:id="@+id/button2" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentRight="true" 
      android:text="btn2"/> 

    <ScrollView android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:layout_below="@id/button1"> 

     <TextView android:id="@+id/txt2" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:layout_below="@id/button2" 
        android:text="txt2"/> 
    </ScrollView> 
</RelativeLayout> 
+0

如果你想在你的答案中包含代碼**,請在每行代碼**前放4個空格。謝謝!查看更多信息[在此頁面](http://stackoverflow.com/editing-help)。 – 2011-05-01 07:41:17

相關問題