0

android:layout_alignParentBottom="true"用来在父底部对齐,但对于这种特殊情况是无效的。Parent 是一个相对布局,它具有固定的大小和更大的屏幕高度。现在我需要在屏幕底部而不是父底部放置一个对齐的文本视图。如何到达?谢谢你。

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

    <RelativeLayout
        android:id="@+id/blogLayout"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

        <WebView
            android:id="@+id/webviewBlog"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:textColor="@android:color/black" 
            android:scrollbars="none"
            android:fitsSystemWindows="true" />

    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/Volver"
        android:layout_width="fill_parent"
        android:layout_height="40dp"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true">

        <TextView
            android:id="@+id/Volvertxt"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:text="Volver"
            android:textColor="@android:color/white"
            android:textSize="30px"
            android:gravity="center"
            android:clickable="true"
            android:onClick="onClickVolver" />
    </RelativeLayout>

</RelativeLayout>
4

2 回答 2

1
I have modified your code hope it solves your problem


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

        <WebView
            android:id="@+id/webviewBlog"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:textColor="@android:color/black" 
            android:scrollbars="none"
            android:fitsSystemWindows="true" />


        <TextView
            android:id="@+id/Volvertxt"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:text="Volver"
            android:textColor="@android:color/white"
            android:textSize="30px"
            android:gravity="center"
            android:clickable="true"
            android:onClick="onClickVolver" />

</RelativeLayout>
于 2012-08-20T10:08:54.687 回答
0

那是因为,您dp以父布局为单位给出高度。让它match_parent

编辑

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


        <WebView
            android:id="@+id/webviewBlog"
            android:layout_width="fill_parent"
            android:layout_height="600dp"
            android:textColor="@android:color/black" 
            android:scrollbars="none"
            android:fitsSystemWindows="true" />



    <RelativeLayout
        android:id="@+id/Volver"
        android:layout_width="fill_parent"
        android:layout_height="40dp"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true">

        <TextView
            android:id="@+id/Volvertxt"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:text="Volver"
            android:textColor="@android:color/white"
            android:textSize="30px"
            android:gravity="center"
            android:clickable="true"
            android:onClick="onClickVolver" />
    </RelativeLayout>

</RelativeLayout>
于 2012-08-20T09:40:21.537 回答