簡體   English   中英

屏幕底部的android align元素

[英]android align element at bottom of the screen

我正在使用android:layout_alignParentBottom="true"在父底部對齊,但是對於這種特殊情況無效。 父級是一種相對布局,具有固定的大小和更大的屏幕高度。 現在,我需要將textview放在屏幕底部而不是父級底部對齊。 如何到達? 謝謝。

<?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>
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>

這是因為,您以父布局的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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM