2011-05-30 70 views
0

當我進入橫向模式時,我的活動底部的兩個按鈕不可見。屏幕應該已自動轉換爲可滾動。是否必須向我的xml或清單文件添加內容?查看設備方向變化時的問題

<?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:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="@string/hello" 
     /> 
    <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="Text in Hindi->" 
     />  
    <TextView 
     style="@style/PassageStyle" 
     android:id="@+id/hindi" 
     android:textSize="30sp" 
     android:gravity="center" 
     /> 
    <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="Corresponding Text in English->" 
     /> 
    <TextView 
     style="@style/PassageStyle" 
     android:id="@+id/english" 
     android:textSize="30dip" 
     android:gravity="center" 
     /> 
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent">  
     <Button 
      android:id="@+id/listen_Button" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="60dip" 
      android:text="@string/listen" 
      /> 
     <Button 
      android:id="@+id/slow_button" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Slow" 
      android:layout_marginLeft="30dip" 
      android:layout_toRightOf="@id/listen_Button" 
      android:layout_alignTop="@id/listen_Button" 
     /> 
     <Button 
      android:id="@+id/voice" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/voice" 
      android:layout_alignLeft="@id/listen_Button" 
      android:layout_below="@id/listen_Button" 
      /> 
     <Button 
      android:id="@+id/next_button" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Next" 
      android:layout_below="@id/slow_button" 
      android:layout_alignLeft="@id/slow_button" 
      /> 
    </RelativeLayout>   

</LinearLayout> 
+0

什麼讓你有那個想法? – Maximus 2011-05-30 19:26:11

+0

我有另一個Listactivity爲它工作fine.Any解決上述問題? – vagrawal13 2011-05-30 19:28:57

+1

ListView的內容本質上是可滾動的,所以一切都會好的。在LinearLayout中一個接一個地放置的單個視圖不是。 – Maximus 2011-05-30 19:32:06

回答

0

你在哪裏定義你的ScrollView?

試試這樣說:

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

<LinearLayout 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 

... other stuff ... 

</LinearLayout> 

</ScrollView> 
0

,如果你想你的屏幕上滾動,你應該添加一個ScrollView作爲根佈局是這樣的:「在screeen應該自動轉換成成滾動」

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_heigth="fill_parent" 
    android:layout_width="fill_parent"> 
    <LinearLayout 
     android:orientation="vertical" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     > 
    <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="@string/hello" 
     /> 
    <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="Text in Hindi->" 
     />  
    <TextView 
     style="@style/PassageStyle" 
     android:id="@+id/hindi" 
     android:textSize="30sp" 
     android:gravity="center" 
     /> 
    <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="Corresponding Text in English->" 
     /> 
    <TextView 
     style="@style/PassageStyle" 
     android:id="@+id/english" 
     android:textSize="30dip" 
     android:gravity="center" 
     /> 
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent">  
     <Button 
      android:id="@+id/listen_Button" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="60dip" 
      android:text="@string/listen" 
      /> 
     <Button 
      android:id="@+id/slow_button" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Slow" 
      android:layout_marginLeft="30dip" 
      android:layout_toRightOf="@id/listen_Button" 
      android:layout_alignTop="@id/listen_Button" 
     /> 
     <Button 
      android:id="@+id/voice" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/voice" 
      android:layout_alignLeft="@id/listen_Button" 
      android:layout_below="@id/listen_Button" 
      /> 
     <Button 
      android:id="@+id/next_button" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Next" 
      android:layout_below="@id/slow_button" 
      android:layout_alignLeft="@id/slow_button" 
      /> 
    </RelativeLayout>   

</LinearLayout> 
</ScrollView> 
相關問題