我将RelativeLayout保存在ScrollView中,但它仍然没有变得可滚动,而且我没有额外的空间来拖放我的布局中的更多视图。 plzz帮助.. 我是android新手任何答案对我都有很大的帮助....在此先感谢.......
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#b8fce8"
android:gravity="bottom" >
<TextView
android:id="@+id/txtDocProfile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="Doctor Profile"
android:gravity="center_horizontal"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/lblDocName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/txtDocProfile"
android:layout_marginTop="14dp"
android:text="Name :"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/txtDocName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/lblDocName"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/tetSpecilazation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/lblDocSpeciality"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/lblDocQualification"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/tetSpecilazation"
android:layout_marginTop="22dp"
android:text="Qualification :"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/txtDocQualification"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/lblDocQualification"
android:layout_below="@+id/lblDocQualification"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/lblDocSpeciality"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/txtDocName"
android:layout_marginTop="16dp"
android:text="Specilization :"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/lblAddress1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="Address 1 :"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/txtDocQualification"
android:layout_alignParentRight="true"
android:layout_below="@+id/lblAddress1"
android:gravity="top|left"
android:inputType="textMultiLine"
android:lines="4"
android:scrollHorizontally="false"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/lblContact"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/textView1"
android:layout_marginTop="27dp"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/lblMobile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_alignRight="@+id/txtDocQualification"
android:layout_below="@+id/lblContact"
android:text="Mobile No :"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/txtDocMobNo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/lblMobile"
android:layout_alignBottom="@+id/lblMobile"
android:layout_toRightOf="@+id/lblMobile"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="@+id/btnCallMob"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/txtDocMobNo"
android:layout_marginRight="16dp"
android:text="Call" />
<TextView
android:id="@+id/lblDocPhone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/lblMobile"
android:layout_alignParentBottom="true"
android:text="Landline "
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/txtDocPhoneNo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toRightOf="@+id/lblMobile"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="@+id/btnCallPhone"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/btnCallMob"
android:layout_alignParentBottom="true"
android:text="Call" />
</RelativeLayout>
</ScrollView>
答案 0 :(得分:0)
<?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"
android:orientation="vertical" >
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<!--put here your button and all other-->
</LinearLayout>
</ScrollView>
</RelativeLayout>
答案 1 :(得分:0)
实际上它因为这个而无效
android:layout_alignParentBottom="true"
所以最后一个组件放在相对布局的底部而不是伸展到任何地方
如果要拉伸相对布局,请尝试使用
相互垂直添加组件堆栈 android:layout_below="@+id/yourComponentBefore"
我举个例子
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#b8fce8"
android:gravity="bottom" >
<TextView
android:id="@+id/ComponentOne"
android:layout_width="match_parent"
android:layout_height="450dp"
android:background="#CFCFCF" />
<TextView
android:id="@+id/ComponentTwo"
android:layout_width="match_parent"
android:layout_height="450dp"
android:layout_below="@+id/ComponentOne"
android:background="#FFFFFF" />
<TextView
android:id="@+id/ComponentThree"
android:layout_width="match_parent"
android:layout_height="450dp"
android:layout_below="@+id/ComponentTwo"
android:background="#000000" />
</RelativeLayout>