Android: layout_height = & quot; fill_parent & quot; does not work.

Source: Internet
Author: User

Android: layout_height = "fill_parent" does not work.

For example, the components added to the ScrollView cannot be automatically scaled to the screen height in any way.

Layout file.

[Html]
<? Xml version = "1.0" encoding = "UTF-8"?>
<! -- Background: blue -->
<ScrollView xmlns: android = "http://schemas.android.com/apk/res/android"
Android: id = "@ + id/scrollView1"
Android: layout_width = "fill_parent"
Android: layout_height = "fill_parent"
Android: background = "# 0000ff">
 
<! -- Background: Green -->
 
<LinearLayout
Android: id = "@ + id/linearLayout1"
Android: layout_width = "fill_parent"
Android: layout_height = "fill_parent"
Android: background = "#00ff00">
 
<TextView
Android: id = "@ + id/textView1"
Android: layout_width = "wrap_content"
Android: layout_height = "fill_parent"
Android: layout_weight = "1"
Android: text = "Hello Android.">
</TextView>
</LinearLayout>
 
</ScrollView>

.

.

Although android: layout_height = "fill_parent" has been set, the entire LinearLayout and TextView cannot be filled with the entire screen.


Solution.

Add an android: fillViewport = "true" attribute to ScrollView. As the name suggests, this attribute allows components in ScrollView to fill it.


Modified

(

Related Article

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.