android - 如何删除android中不需要的重叠

标签 android android-layout overlap

我正在尝试制作一个 Android 界面,但我有一些与 View 重叠的问题。

这是我的代码。它在一个标签中,但我把标签部分切掉了。如果你需要,我会添加。

更新:我忘了写我有很多 TextView,而不是只有一个

<FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="5dp" >

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">

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

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

                <TextView
                    android:text="welcome"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_alignParentTop="true" />

                <!-- A lot of TextView as the one above -->

                </LinearLayout>
            </ScrollView>

            <RelativeLayout
                android:id="@+id/InnerRelativeLayout"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true" >

                <Button
                     android:id="@+id/add"
                     android:layout_height="wrap_content"
                     android:layout_alignParentRight="true"
                     android:layout_width="fill_parent"
                     android:text="@string/add" />
            </RelativeLayout>
        </RelativeLayout>
    </FrameLayout>

这就是它的输出。如您所见,在底部,文本位于按钮后面,但我希望它们采用两种不同的布局

Screenshot

最佳答案

尽量将它放在按钮上方。

<RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

        <ScrollView                
            android:orientation="vertical"
            android:layout_above="@+id/InnerRelativeLayout" //Add this
            android:layout_height="fill_parent"
            android:layout_width="fill_parent">

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

            <TextView
                android:text="welcome"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true" />

            </LinearLayout>
        </ScrollView>

        <RelativeLayout
            android:id="@+id/InnerRelativeLayout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true" >

            <Button
                 android:id="@+id/add"
                 android:layout_height="wrap_content"
                 android:layout_alignParentRight="true"
                 android:layout_width="fill_parent"
                 android:text="@string/add" />
        </RelativeLayout>
    </RelativeLayout>
</FrameLayout>

关于android - 如何删除android中不需要的重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7997676/

相关文章:

java - 这个RadioGroup布局或其LinearLayout父级是无用的

android - RecyclerView 和动画中的 notifyItemInserted()

java - 安卓:Epub 文件在模拟器/安卓设备中不显示图像

android - 如何从我的 android TableView 中的数据库中获取数据作为列

android - 与 ConstraintLayout 一起使用时,按钮文本不换行

javascript - HTML5 Canvas 描边重叠

javascript - 两个旋转元素之间的碰撞

android - Firebase 身份验证在 Release模式下失败

android - 如何在onPictureTaken中旋转和翻转位图

xamarin - Oxyplot:防止 X 轴标签重叠