我的ScrollView无法正常工作我无法滚动整个视图我尝试添加和删除重量但它不起作用有人可以告诉我我做错了什么?下面是我的XML代码。
<?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"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:background="@android:color/darker_gray"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:src="@drawable/referfriend_screen" />
<TextView
android:id="@+id/refersharemessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp"
android:padding="0dp"
android:text="Share your referal code with a friend and earn Rs. 150/- for every share that translate to a sale" />
<TextView
android:id="@+id/yourcode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:layout_marginBottom="25dp"
android:text="Your Code" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/sharecodeWhatsapp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="30dp"
android:background="@drawable/draw_login_edit_text"
android:orientation="horizontal"
android:padding="10dp"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0.5"
android:src="@drawable/whatsapp" />
<TextView
android:id="@+id/sharecodeWhatsapptext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0.5"
android:text="Whatsapp Invite" />
</LinearLayout>
<LinearLayout
android:id="@+id/shareCodeFacebook"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="@drawable/draw_login_edit_text"
android:orientation="horizontal"
android:padding="10dp"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0.5"
android:src="@drawable/fb_icon" />
<TextView
android:id="@+id/sharecodefacebooktext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0.5"
android:text="Facebook Invite" />
</LinearLayout>
<LinearLayout
android:id="@+id/shareCodeMore"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:background="@drawable/draw_login_edit_text"
android:orientation="horizontal"
android:padding="10dp"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:src="@drawable/more_icon" />
<TextView
android:id="@+id/sharecodemoretext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0.5"
android:text="More Apps " />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<Button
android:id="@+id/referCode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@drawable/item_view_add_to_cart_click"
android:text="YTH45T"
android:textColor="@color/white_bg" />
</RelativeLayout>
</LinearLayout>
</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">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/ll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:background="@android:color/darker_gray"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:src="@drawable/referfriend_screen" />
<TextView
android:id="@+id/refersharemessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp"
android:padding="0dp"
android:text="Share your referal code with a friend and earn Rs. 150/- for every share that translate to a sale" />
<TextView
android:id="@+id/yourcode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:layout_marginBottom="25dp"
android:text="Your Code" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:id="@+id/sharecodeWhatsapp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="30dp"
android:background="@drawable/draw_login_edit_text"
android:gravity="center"
android:orientation="horizontal"
android:padding="10dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/whatsapp" />
<TextView
android:id="@+id/sharecodeWhatsapptext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Whatsapp Invite" />
</LinearLayout>
<LinearLayout
android:id="@+id/shareCodeFacebook"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="@drawable/draw_login_edit_text"
android:gravity="center"
android:orientation="horizontal"
android:padding="10dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/fb_icon" />
<TextView
android:id="@+id/sharecodefacebooktext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Facebook Invite" />
</LinearLayout>
<LinearLayout
android:id="@+id/shareCodeMore"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="@drawable/draw_login_edit_text"
android:orientation="horizontal"
android:padding="10dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:src="@drawable/more_icon" />
<TextView
android:id="@+id/sharecodemoretext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0.5"
android:text="More Apps " />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<Button
android:id="@+id/referCode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/ll"
android:layout_centerInParent="true"
android:background="@drawable/item_view_add_to_cart_click"
android:text="YTH45T"
android:textColor="@color/white_bg" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
答案 1 :(得分:0)
删除LinearLayout并使Relative布局成为scrollview的直接子项,它将开始滚动。