本文介绍了以下2项Android的相对布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这样一个相对布局:
i have a relative layout like this:
<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>
这篇关于以下2项Android的相对布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!