Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android – 如何使用RelativeLayout实现以下结果?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
图片http://img838.imageshack.us/img838/1402/picse.png

如何在Pic中进行布局. 2仅使用RelativeLayout.下面是第一个屏幕截图的xml布局.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
        xmlns:android="http://scheR_152_11845@as.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
<TextView
    android:id="@+id/timer_textview"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:layout_marginTop="10dip"
    android:textSize="30sp"
    android:layout_alignParentTop="true"
    android:text="@String/timer_start" />

<ListView 
    android:id="@+id/questions_listview"
    android:layouT_Below="@id/timer_textview"  
    android:layout_width="wrap_content"
    android:layout_height="fill_parent" />

<Button android:id="@+id/true_btn"
    android:text="@String/true_option"
    android:layout_alignParentBottom="true"
    android:layout_weight="1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

<Button
    android:id="@+id/false_btn"
    android:text="@String/false_option"
    android:layout_toRightOf="@id/true_btn"
    android:layout_alignBaseline="@id/true_btn"
    android:layout_weight="1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />
</RelativeLayout>

解决方法

您可以在底部使用LinearLayout来实现此目的.但是你只想使用RelativeLayout布局:
<RelativeLayout android:layout_width="fill_parent" ... >

...    

<View android:id="@+id/Helper" 
android:layout_width="0dp"
android:layout_height="0dp" 
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />

<Button android:id="@+id/true_btn"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" 
android:layout_toLeftOf="@id/Helper"/>

<Button
android:id="@+id/false_btn"
android:layout_alignBaseline="@id/true_btn"
android:layout_alignParentright="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" 
android:layout_toRightOf="@id/Helper" />

</RelativeLayout>

你真的不能使用嵌套布局吗?

大佬总结

以上是大佬教程为你收集整理的android – 如何使用RelativeLayout实现以下结果?全部内容,希望文章能够帮你解决android – 如何使用RelativeLayout实现以下结果?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。