Android RelativeLayout下面有2个视图 [英] Android RelativeLayout below 2 views
本文介绍了Android RelativeLayout下面有2个视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这样的RelativeLayout
:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/single_row"
android:padding="12dip">
<ImageView
android:id="@+id/page_image"
android:layout_marginRight="6dip"
android:layout_width="66dip"
android:layout_height="66dip"
android:layout_alignParentLeft="true"
android:src="@drawable/no_photo" />
<TextView
android:id="@+id/page_name"
style="@style/pulse_content"
android:layout_alignTop="@id/page_image"
android:layout_toRightOf="@id/page_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/page_desc"
android:layout_below="@id/page_name"
style="@style/pulse_content"
android:layout_alignLeft="@id/page_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Principal Consultant" />
<Button
android:id="@+id/follow_button"
android:layout_below="@id/author_image"
android:layout_marginTop="15dip"
android:layout_alignParentBottom="true"
android:text="Follow"
style="@style/follow_button" />
</RelativeLayout>
我遇到的问题是我希望follow_button
低于page_desc
和page_image
.有时page_desc
内容的高度将大于图像的大小,有时则不会.问题是,如果我在图像或说明下方设置了follow_button
,则另一个将被剪切.有没有一种有效/有效的方法来确保图像或page_desc
始终在按钮上方可见?
The issue I'm running into is that I want the follow_button
to be below both the page_desc
as well as the page_image
. Sometimes the page_desc
content will have a height bigger than the size of the image, sometimes not. The issue is that if I set the follow_button
below either the image or the description, then the other one will get clipped. Is there an efficient / effective way to ensure that the image or page_desc
are always visible and above the button?
推荐答案
在这里:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/single_row"
android:padding="12dip">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/page_image"
android:layout_marginRight="6dip"
android:layout_width="66dip"
android:layout_height="66dip"
android:layout_alignParentLeft="true"
android:src="@drawable/no_photo" />
<TextView
android:id="@+id/page_name"
style="@style/pulse_content"
android:layout_alignTop="@id/page_image"
android:layout_toRightOf="@id/page_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/page_desc"
android:layout_below="@id/page_name"
style="@style/pulse_content"
android:layout_alignLeft="@id/page_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Principal Consultant" />
</RelativeLayout>
<Button
android:id="@+id/follow_button"
android:layout_marginTop="15dip"
android:text="Follow"
style="@style/follow_button" />
</LinearLayout>
这篇关于Android RelativeLayout下面有2个视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文