ScrollView cannot use RelativeLayout Solution

Source: Internet
Author: User

Meaning of RelativeLayout:

Layout the relative layout of each part. Make proper use of the interface space.

I. Limitations of ScrollView:

Slide can only be linearlayout, and even the entire layout cannot have RelativeLayout. This makes people think that the ScrollView control is a little chicken. Actually it is not ..........

The layout of linearlayout and RelativeLayout is only the difference of space interval on the interface. In liearlayout, one <View/> can occupy space.RelativeLayoutYou can use <View/>.


Ii. View usage

<View

Android: layout_width = "fill_parent"
Android: layout_height = "10sp"

/>

III,Example

The following interface

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/0646133559-0.jpg "title =" li1.jpg "/>

1) UseRelativeLayoutEasy to implement

RelativeLayoutCode

<RelativeLayout xmlns: android =" http://schemas.android.com/apk/res/android "Xmlns: tools =" http://schemas.android.com/tools "Android: layout_width =" match_parent "android: layout_height =" fill_parent "tools: context = ". clientActivity "> <ImageView android: id =" @ + id/clientinfo_headpicture "android: layout_width =" 90sp "android: layout_height =" 90sp "android: background = "@ drawable/client_pic_back" android: src = "@ drawable/client_pic_src"/> <TextView android: id = "@ + id/client_tel" android: layout_width = "match_parent" android: layout_height = "30sp" android: Photo = "@ + id/clientinfo_headpicture" android: layout_toRightOf = "@ + id/clientinfo_heaspicture" android: background = "@ color/black" android: EMS = "12" android: singleLine = "true" android: text = "phone number" android: textColor = "@ color/white"/> <Button android: id = "@ + id/client_tel_edit" android: layout_width = "50sp" android: layout_height = "30sp" android: layout_above = "@ + id/client_tel" android: layout_alignParentRight = "true" android: background = "@ drawable/cliebt_button_edittel" android: text = "edit" android: textColor = "@ color/blue"/> <TextView android: layout_width = "match_parent" android: layout_height = "30sp" android: layout_alignLeft = "@ + id/client_tel" android: layout_alignParentTop = "true" android: background = "@ color/black" android: singleLine = "true" android: text = "username" android: textColor = "@ color/white" android: textSize = "24sp"/> <View android: id = "@ + id/view1" android: layout_width = "fill_parent" android: layout_height = "10sp" android: layout_alignParentRight = "true" android: layout_below = "@ + id/clientinfo_headpicture" android: background = "@ color/blue"/> <RelativeLayout android: layout_width = "fill_parent" android: layout_height = "match_parent" android: layout_alignParentLeft = "true" android: layout_below = "@ + id/view1" android: background = "@ drawable/client_moreinfo_back"> <Button android: id = "@ + id/client_myaddress" android: layout_width = "50sp" android: layout_height = "30sp" android: background = "@ drawable/client_address"/> <TextView android: id = "@ + id/client_myaddress_text" android: layout_width = "wrap_content" android: layout_height = "30sp" android: layout_alignBaseline = "@ + id/client_myaddress" android: layout_alignBottom = "@ + id/client_myaddress" android: layout_toRightOf = "@ + id/client_myaddress" android: text = "My address" android: textColor = "@ color/blue" android: textSize = "24sp"/> <View android: id = "@ + id/client_myaddress_div" android: layout_width = "fill_parent" android: layout_height = "1sp" android: layout_alignParentLeft = "true" android: layout_below = "@ + id/client_myaddress" android: background = "@ color/blue"/> <TextView android: id = "@ + id/client_myaddress_addtext" android: layout_width = "160sp" android: layout_height = "50sp" android: layout_alignLeft = "@ + id/client_myaddress_div" android: layout_below = "@ + id/client_myaddress_div" android: layout_marginLeft = "14sp" android: text = "31 building 127 bedroom phone 18607060000" android: textColor = "@ color/blue"/> <Button android: id = "@ + id/client_myaddress_edit" android: layout_width = "40sp" android: layout_height = "40sp" android: layout_alignRight = "@ + id/client_myaddress_div" android: layout_alignTop = "@ + id/client_myaddress_addtext" android: background = "@ drawable/client_edit"/> <View android: id = "@ + id/client_buyhistory_div" android: layout_width = "fill_parent" android: layout_height = "5sp" android: layout_alignParentLeft = "true" android: layout_below = "@ + id/client_myaddress_addtext" android: background = "@ color/blue"/> <Button android: id = "@ + id/client_buyhistory" android: layout_width = "50sp" android: layout_height = "30sp" android: layout_below = "@ + id/client_buyhistory_div" android: layout_marginTop = "1sp" android: layout_toLeftOf = "@ + id/client_myaddress_text" android: background = "@ drawable/client_shopcar"/> <TextView android: id = "@ + id/client_buyhistory_text" android: layout_width = "100sp" android: layout_height = "30sp" android: layout_alignRight = "@ + id/client_myaddress_text" android: layout_alignTop = "@ + id/client_buyhistory" android: text = "purchased" android: textColor = "@ color/blue" android: textSize = "24sp"/> <View android: id = "@ + id/client_buyhistory_div_div" android: layout_width = "fill_parent" android: layout_height = "1sp" android: layout_alignParentLeft = "true" android: layout_below = "@ + id/client_buyhistory" android: background = "@ color/blue"/> <TextView android: id = "@ + id/client_buyhistory_info" android: layout_width = "160sp" android: layout_height = "30sp" android: layout_alignLeft = "@ + id/client_buyhistory_div_div" android: layout_below = "@ + id/client_buyhistory_div_div" android: text = "Beijing Roast Duck 100 yuan" android: textColor = "@ color/blue"/> <Button android: id = "@ + id/paper" android: layout_width = "40sp" android: layout_height = "40sp" android: layout_alignParentRight = "true" android: layout_centerVertical = "true" android: background = "@ drawable/client_edit"/> <View android: id = "@ + id/client_store_div" android: layout_width = "fill_parent" android: layout_height = "5sp" android: layout_alignParentRight = "true" android: layout_below = "@ + id/client_buyhistory_eidt" android: background = "@ color/blue"/> <Button android: id = "@ + id/client_store" android: layout_width = "50sp" android: layout_height = "30sp" android: layout_alignParentLeft = "true" android: layout_below = "@ + id/client_store_div" android: background = "@ drawable/client_stored"/> <TextView android: id = "@ + id/client_store_text" android: layout_width = "80sp" android: layout_height = "30sp" android: layout_alignBaseline = "@ + id/client_store" android: layout_alignBottom = "@ + id/client_store" android: layout_alignLeft = "@ + id/client_myaddress_text" android: text = "favorites" android: textColor = "@ color/blue" android: textSize = "24sp"/> <View android: id = "@ + id/client_store_div_div" android: layout_width = "fill_parent" android: layout_height = "1sp" android: layout_alignParentLeft = "true" android: layout_below = "@ + id/client_store" android: background = "@ color/blue"/> <Button android: id = "@ + id/client_store_edit" android: layout_width = "40sp" android: layout_height = "40sp" android: layout_alignParentRight = "true" android: layout_alignTop = "@ + id/client_store_info" android: background = "@ drawable/client_edit"/> <View android: id = "@ + id/View01" android: layout_width = "fill_parent" android: layout_height = "5sp" android: layout_alignParentBottom = "true" android: layout_centerHorizontal = "true" android: background = "@ color/blue"/> <TextView android: id = "@ + id/client_store_info" android: layout_width = "160sp" android: layout_height = "40sp" android: layout_alignLeft = "@ + id/View01" android: layout_below = "@ + id/client_store_div_div" android: text = "Beijing Roast Duck 30 RMB" android: textColor = "@ color/blue"/> </RelativeLayout>



However, because a project uses TabHost, the layout of the child activity is limited and the layout above exceeds the range. Therefore, ScrollView is used. To achieve the above layout, the <View/> control is used.

2) the code for using the view control is as follows:

<ScrollView xmlns: android =" http://schemas.android.com/apk/res/android "Xmlns: tools =" http://schemas.android.com/tools "Android: layout_width =" wrap_content "android: layout_height =" wrap_content "android: fadingEdge =" vertical "android: scrollbars =" vertical "> <LinearLayout android: orientation = "vertical" android: layout_width = "fill_parent" android: layout_height = "match_parent" android: background = "@ drawable/account_pic_back"> <TextView android: layout_width = "match_parent" android: layout_height = "30sp" android: background = "@ color/black" android: singleLine = "true" android: text = "username" android: textColor = "@ color/white" android: textSize = "24sp"/> <LinearLayout android: orientation = "horizontal" android: layout_width = "fill_parent" android: layout_height = "match_parent" android: background = "@ drawable/account_pic_back"> <ImageView android: id = "@ + id/clientinfo_headpicture" android: layout_width = "90sp" android: layout_height = "90sp" android: background = "@ drawable/client_pic_back" android: src = "@ drawable/client_pic_src"/> <Button android: id = "@ + id/client_tel_edit" android: layout_width = "50sp" android: layout_height = "30sp" android: background = "@ drawable/cliebt_button_edittel" android: text = "edit" android: textColor = "@ color/blue"/> </LinearLayout> <TextView android: id = "@ + id/client_tel" android: layout_width = "match_parent" android: layout_height = "30sp" android: background = "@ color/black" android: EMS = "12" android: singleLine = "true" android: text = "phone number" android: textColor = "@ color/white"/> <View android: layout_width = "fill_parent" android: layout_height = "10sp" android: background = "@ color/blue"/> <LinearLayout android: orientation = "horizontal" android: layout_width = "fill_parent" android: layout_height = "match_parent" android: background = "@ drawable/account_pic_back"> <Button android: id = "@ + id/client_myaddress" android: layout_width = "50sp" android: layout_height = "30sp" android: background = "@ drawable/client_address"/> <TextView android: id = "@ + id/client_myaddress_text" android: layout_width = "wrap_content" android: layout_height = "30sp" android: text = "My address" android: textColor = "@ color/blue" android: textSize = "24sp"/> </LinearLayout> <View android: layout_width = "fill_parent" android: layout_height = "1sp" android: background = "@ color/blue"/> <LinearLayout android: orientation = "horizontal" android: layout_width = "fill_parent" android: layout_height = "match_parent" android: background = "@ drawable/account_pic_back"> <TextView android: id = "@ + id/client_myaddress_addtext" android: layout_width = "160sp" android: layout_height = "50sp" android: layout_alignLeft = "@ + id/client_myaddress_div" android: layout_below = "@ + id/client_myaddress_div" android: layout_marginLeft = "14sp" android: text = "31 building 127 bedroom phone 18607060000" android: textColor = "@ color/blue"/> <View android: layout_width = "100sp" android: layout_height = "40sp"/> <Button android: id = "@ + id/client_myaddress_edit" android: layout_width = "40sp" android: layout_height = "40sp" android: background = "@ drawable/client_edit"/> </LinearLayout> <View android: layout_width = "fill_parent" android: layout_height = "10sp" android: background = "@ color/blue"/> <LinearLayout android: orientation = "horizontal" android: layout_width = "fill_parent" android: layout_height = "match_parent" android: background = "@ drawable/account_pic_back"> <Button android: id = "@ + id/client_buyhistory" android: layout_width = "50sp" android: layout_height = "30sp" android: layout_marginTop = "1sp" android: background = "@ drawable/client_shopcar"/> <TextView android: id = "@ + id/client_buyhistory_text" android: layout_width = "100sp" android: layout_height = "30sp" android: text = "purchased" android: textColor = "@ color/blue" android: textSize = "24sp"/> </LinearLayout> <View android: id = "@ + id/view1" android: layout_width = "fill_parent" android: layout_height = "1sp" android: background = "@ color/blue"/> <LinearLayout android: orientation = "horizontal" android: layout_width = "fill_parent" android: layout_height = "match_parent" android: background = "@ drawable/account_pic_back"> <TextView android: id = "@ + id/client_buyhistory_info" android: layout_width = "160sp" android: layout_height = "30sp" android: text = "Beijing Roast Duck RMB 100" android: textColor = "@ color/blue"/> <View android: layout_width = "100sp" android: layout_height = "40sp"/> <Button android: id = "@ + id/client_buyhistory_eidt" android: layout_width = "40sp" android: layout_height = "40sp" android: background = "@ drawable/client_edit"/> </LinearLayout> <View android: layout_width = "fill_parent" android: layout_height = "1sp" android: background = "@ color/blue"/> <LinearLayout android: orientation = "horizontal" android: layout_width = "fill_parent" android: layout_height = "match_parent" android: background = "@ drawable/account_pic_back"> <Button android: id = "@ + id/client_store" android: layout_width = "50sp" android: layout_height = "30sp" android: background = "@ drawable/client_stored"/> <TextView android: id = "@ + id/client_store_text" android: layout_width = "80sp" android: layout_height = "30sp" android: text = "favorites" android: textColor = "@ color/blue" android: textSize = "24sp"/> <View android: layout_width = "fill_parent" android: layout_height = "1sp" android: background = "@ color/blue"/> </LinearLayout> <LinearLayout android: orientation = "horizontal" android: layout_width = "fill_parent" android: layout_height = "match_parent" android: background = "@ drawable/account_pic_back"> <TextView android: id = "@ + id/client_store_info" android: layout_width = "160sp" android: layout_height = "40sp" android: text = "Beijing Roast Duck 30 RMB" android: textColor = "@ color/blue"/> <View android: layout_width = "100sp" android: layout_height = "40sp"/> <Button android: id = "@ + id/client_store_edit" android: layout_width = "40sp" android: layout_height = "40sp" android: background = "@ drawable/client_edit"/> </LinearLayout> <View android: layout_width = "fill_parent" android: layout_height = "5sp" android: background = "@ color/blue"/> </LinearLayout> </ScrollView>



Perfect calling through ViewRelativeLayoutEffect

This article is from the "lilin9105" blog, please be sure to keep this source http://7071976.blog.51cto.com/7061976/1217017

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.