在屏幕下方的Android对齐元素 [英] android align element at bottom of the screen
本文介绍了在屏幕下方的Android对齐元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用的android:layout_alignParentBottom =真正的
在父母底部对齐但对于这种特殊情况下是无效的。家长是一个相对的布局已固定的尺寸和更大的屏幕的高度。现在,我需要把在屏幕下方,而不是家长底部对齐一个TextView。如何到达呢?谢谢你。
<?XML版本=1.0编码=UTF-8&GT?;
<的RelativeLayout的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =match_parent
机器人:layout_height =600dp的> < RelativeLayout的
机器人:ID =@ + ID / blogLayout
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT> <的WebView
机器人:ID =@ + ID / webviewBlog
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:文字颜色=@机器人:彩色/黑白
机器人:滚动条=无
机器人:fitsSystemWindows =真/> < / RelativeLayout的> < RelativeLayout的
机器人:ID =@ + ID /回归
机器人:layout_width =FILL_PARENT
机器人:layout_height =40dp
机器人:layout_alignParentBottom =真
机器人:layout_alignParentLeft =真正的> <的TextView
机器人:ID =@ + ID / Volvertxt
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:layout_alignParentBottom =真
机器人:layout_alignParentLeft =真
机器人:文字=回归
机器人:文字颜色=@机器人:彩色/白
机器人:TEXTSIZE =30像素
机器人:比重=中心
机器人:可点击=真
安卓的onClick =onClickVolver/>
< / RelativeLayout的>< / RelativeLayout的>
解决方案
这是因为,你在 DP
父布局的单位给予高度。让 match_parent
。
修改
<?XML版本=1.0编码=UTF-8&GT?;
<的RelativeLayout的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =match_parent
机器人:layout_height =match_parent>
<的WebView
机器人:ID =@ + ID / webviewBlog
机器人:layout_width =FILL_PARENT
机器人:layout_height =600dp的
机器人:文字颜色=@机器人:彩色/黑白
机器人:滚动条=无
机器人:fitsSystemWindows =真/> < RelativeLayout的
机器人:ID =@ + ID /回归
机器人:layout_width =FILL_PARENT
机器人:layout_height =40dp
机器人:layout_alignParentBottom =真
机器人:layout_alignParentLeft =真正的> <的TextView
机器人:ID =@ + ID / Volvertxt
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:layout_alignParentBottom =真
机器人:layout_alignParentLeft =真
机器人:文字=回归
机器人:文字颜色=@机器人:彩色/白
机器人:TEXTSIZE =30像素
机器人:比重=中心
机器人:可点击=真
安卓的onClick =onClickVolver/>
< / RelativeLayout的>< / RelativeLayout的>
I am using android:layout_alignParentBottom="true"
to align at parent bottom but for this particular case is not valid. Parent is a relative layout that has fixed size and bigger that screen height. Now I need to place a textview aligned at bottom of screen and not parent bottom. How to reach it? thank you.
<?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>
解决方案
That is because, you are giving height in dp
units of the parent layout. Make it match_parent
.
EDIT:
<?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>
这篇关于在屏幕下方的Android对齐元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文