android - ScrollView 不能很好地与 RelativeLayout 一起玩

标签 android xml scrollview android-relativelayout

所以我有一个 ScrollView 作为我布局中的最高级别...在我的 ScrollView 中,我有一个包含其他 View 的 RelativeLayout。问题是 RelativeLayout 没有像它应该的那样覆盖整个布局,它在大约一半的屏幕处被切断。它的宽度是屏幕的整个宽度,但 RelativeLayout 的高度停在 ImageView 底部的位置。这是我的布局代码:

<?xml version="1.0" encoding="utf-8"?>    
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" 
android:background="@drawable/graybck">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >

<ImageView
    android:id="@+id/pPicture"
    android:layout_width="200dip"
    android:layout_height="300dip"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true" />

<TextView
    android:id="@+id/pName"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_marginTop="29dp"
    android:layout_toRightOf="@+id/pPicture"
    android:text="Large Text"
    android:textAppearance="?android:attr/textAppearanceLarge" />

<TextView
    android:id="@+id/pBio"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/pName"
    android:layout_below="@+id/pName"
    android:layout_marginTop="22dp"
    android:text="Medium Text"
    android:textAppearance="?android:attr/textAppearanceMedium" />

<TextView
    android:id="@+id/stats"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_alignTop="@+id/pName"
    android:layout_marginRight="266dp"
    android:text="Loading Stats..." />

</RelativeLayout>

</ScrollView>

非常感谢任何帮助!

最佳答案

<Scrollview> 
    <LinearLayout>
        <RelativeLayout>
        inner part here ...
        </RelativeLayout>
    </LinearLayout>  
</Scrollview>

尝试使用类似的东西。

关于android - ScrollView 不能很好地与 RelativeLayout 一起玩,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14907794/

相关文章:

.net - 使用 .NET 根据模式验证 XML

android - 在 LinearLayout 中设置 ScrollView 的属性 - Android

Android 两种方式 View - Horizo​​ntal Recyclerview inside Vertical Recyclerview

android - 我的 Action_DOWN 和我的 Scrollview 之间的冲突

android - 如何制作更小的 RatingBar?

android - 在少数 Activity 中显示操作栏

java - JAXB:我应该如何整理复杂的嵌套数据结构?

android - 无法跨模块访问 BindingAdapter

android - PDFbox 此字体类型仅支持 8 位代码点

java - 使用 XML 文件在 swing 中构建 GUI