2012-10-26 172 views
0

我有一个滚动视图:滚动视图不工作的布局

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:fillViewport="true" 
    > 
<LinearLayout 
    android:layout_width="500dp" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    android:background="@color/antiquewhiter" 
    android:weightSum="100" 

    > 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="10" 
     android:background="@drawable/green_gradient_top_bar" 

     > 

     <TextView 
      android:id="@+id/log_in_header_text" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerHorizontal="true" 
      android:layout_centerVertical="true" 
      android:text="@string/Einloggen_text" 
      style="@style/headerfromdialogs" /> 

     <ImageView 
      android:id="@+id/log_in_header_exit_image" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignBottom="@+id/log_in_header_text" 
      android:layout_alignParentRight="true" 
      android:layout_marginRight="20dp" 
      android:onClick="finish" 
      android:src="@drawable/x_android" /> 

    </RelativeLayout> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="90" > 

     <TextView 
      android:id="@+id/log_in_benutzername_text" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentTop="true" 
      android:layout_marginLeft="40dp" 
      android:layout_marginTop="80dp" 
      android:text="@string/Benutzername_text" 
      style="@style/dialogsGreenTexts" /> 

     <EditText 
      android:id="@+id/log_in_benutzername_edit_text" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignBaseline="@+id/log_in_benutzername_text" 
      android:layout_alignBottom="@+id/log_in_benutzername_text" 
      android:layout_marginLeft="50dp" 
      android:layout_marginRight="20dp" 
      android:layout_toRightOf="@+id/log_in_benutzername_text" 
      android:ems="10" 
      android:hint="@string/hint_name_log_in" 
      > 

     </EditText> 

     <TextView 
      android:id="@+id/log_in_passwort_text" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignLeft="@+id/log_in_benutzername_text" 
      android:layout_below="@+id/log_in_benutzername_edit_text" 
      android:layout_marginTop="52dp" 
      android:text="@string/Passwort_text" 
      style="@style/dialogsGreenTexts" /> 

     <EditText 
      android:id="@+id/log_in_passwort_edit_text" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignBaseline="@+id/log_in_passwort_text" 
      android:layout_alignBottom="@+id/log_in_passwort_text" 
      android:layout_alignLeft="@+id/log_in_benutzername_edit_text" 
      android:ems="10" 
      android:layout_marginRight="20dp" 
      android:inputType="textPassword" 
      android:hint="@string/hint_passwort_log_in" 
      > 

     </EditText> 

     <Button 
      android:id="@+id/log_in_button" 
      android:layout_width="100dp" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:layout_alignRight="@+id/log_in_passwort_edit_text" 
      android:layout_marginBottom="45dp" 
      android:layout_marginRight="-10dp" 
      android:onClick="logIn" 
      android:text="@string/Login_text" 
      style="@style/bold_text18" /> 
<!--    android:background="@drawable/green_gradient_button" --> 

     <TextView 
      android:id="@+id/log_in_passwort_vergessen_text" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_above="@+id/log_in_button" 
      android:layout_alignLeft="@+id/log_in_passwort_edit_text" 
      android:text="@string/Passwort_vergessen_text" 
      style="@style/dialogsGreenTexts" /> 

     <ProgressBar 
      android:id="@+id/waitProgessBar" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerInParent="true" 
      android:visibility="gone" 
      /> 

     <TextView 
      android:id="@+id/userError" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_above="@+id/log_in_benutzername_edit_text" 
      android:layout_alignLeft="@+id/log_in_benutzername_edit_text" 
      android:layout_marginBottom="5dp" 
      android:visibility="gone" 
      android:textColor="@color/errorRed"/> 

    </RelativeLayout> 

</LinearLayout> 
</ScrollView> 

我要滚动,因为在水平方向我不能看到所有观点我SE XPERIA新诉第二个问题是当我改变方向时,所有视图都打破了。如何改变这种观点,以便在两个方向上正确显示?

但滚动不起作用。有人知道为什么?

+0

是您的布局比大更作为比较,筛选?如果是的话,然后滚动视图来。 –

+0

你在布局里面的子视图是什么,请问清楚... –

+0

粘贴你的整个xml。 –

回答

2

请注意:

1)滚动视图必须有一个孩子(即所有的意见都必须包含滚动视图内单根布局内)

2)滚动型工程时,你的页面大小是更高的屏幕的默认高度。

请检查这些事情,如果仍然无法正常工作...粘贴一些代码以更好地理解问题。

1

试试这个代码

<?xml version="1.0" encoding="utf-8"?> 

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="500dp" 
android:layout_height="wrap_content" 
android:orientation="vertical" 
android:background="@color/antiquewhiter" 
android:weightSum="100" 
> 

<ScrollView 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:fillViewport="true" 
> 

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

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="10" 
    android:background="@drawable/green_gradient_top_bar" 

    > 

    <TextView 
     android:id="@+id/log_in_header_text" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:layout_centerVertical="true" 
     android:text="@string/Einloggen_text" 
     style="@style/headerfromdialogs" /> 

    <ImageView 
     android:id="@+id/log_in_header_exit_image" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignBottom="@+id/log_in_header_text" 
     android:layout_alignParentRight="true" 
     android:layout_marginRight="20dp" 
     android:onClick="finish" 
     android:src="@drawable/x_android" /> 

</RelativeLayout> 

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="90" > 

    <TextView 
     android:id="@+id/log_in_benutzername_text" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:layout_marginLeft="40dp" 
     android:layout_marginTop="80dp" 
     android:text="@string/Benutzername_text" 
     style="@style/dialogsGreenTexts" /> 

    <EditText 
     android:id="@+id/log_in_benutzername_edit_text" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignBaseline="@+id/log_in_benutzername_text" 
     android:layout_alignBottom="@+id/log_in_benutzername_text" 
     android:layout_marginLeft="50dp" 
     android:layout_marginRight="20dp" 
     android:layout_toRightOf="@+id/log_in_benutzername_text" 
     android:ems="10" 
     android:hint="@string/hint_name_log_in" 
     > 

    </EditText> 

    <TextView 
     android:id="@+id/log_in_passwort_text" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@+id/log_in_benutzername_text" 
     android:layout_below="@+id/log_in_benutzername_edit_text" 
     android:layout_marginTop="52dp" 
     android:text="@string/Passwort_text" 
     style="@style/dialogsGreenTexts" /> 

    <EditText 
     android:id="@+id/log_in_passwort_edit_text" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignBaseline="@+id/log_in_passwort_text" 
     android:layout_alignBottom="@+id/log_in_passwort_text" 
     android:layout_alignLeft="@+id/log_in_benutzername_edit_text" 
     android:ems="10" 
     android:layout_marginRight="20dp" 
     android:inputType="textPassword" 
     android:hint="@string/hint_passwort_log_in" 
     > 

    </EditText> 

    <Button 
     android:id="@+id/log_in_button" 
     android:layout_width="100dp" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignRight="@+id/log_in_passwort_edit_text" 
     android:layout_marginBottom="45dp" 
     android:layout_marginRight="-10dp" 
     android:onClick="logIn" 
     android:text="@string/Login_text" 
     style="@style/bold_text18" /> 
     <!-- android:background="@drawable/green_gradient_button" --> 

    <TextView 
     android:id="@+id/log_in_passwort_vergessen_text" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/log_in_button" 
     android:layout_alignLeft="@+id/log_in_passwort_edit_text" 
     android:text="@string/Passwort_vergessen_text" 
     style="@style/dialogsGreenTexts" /> 

    <ProgressBar 
     android:id="@+id/waitProgessBar" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerInParent="true" 
     android:visibility="gone" 
     /> 

    <TextView 
     android:id="@+id/userError" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/log_in_benutzername_edit_text" 
     android:layout_alignLeft="@+id/log_in_benutzername_edit_text" 
     android:layout_marginBottom="5dp" 
     android:visibility="gone" 
     android:textColor="@color/errorRed"/> 

</RelativeLayout> 

</LinearLayout> 
</ScrollView> 
</LinearLayout>