【问题标题】:ViewFlipper height issueViewFlipper 高度问题
【发布时间】:2012-08-20 08:31:54
【问题描述】:

在下面的代码中,viewflipper 并没有占据整个屏幕,它只是环绕textview。为什么会这样?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <ScrollView  
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#0000ff" >

        <ViewFlipper android:id="@+id/ViewFlipper01"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#aa0000"
            android:layout_gravity="center">  

            <TextView
                android:layout_width="match_parent"
                android:layout_height="50dp"></TextView>

        </ViewFlipper>
    </ScrollView>
</LinearLayout>

【问题讨论】:

  • 在滚动视图中尝试android:fillViewport="true"
  • @MMohsinNaeem 这是答案,如果你把它写成答案,我会标记它,谢谢

标签: android layout viewflipper


【解决方案1】:

在scrollView中使用

android:fillViewport="true"

【讨论】:

  • 在 ConstraintLayout 中,尝试android:layout_height="0dp"...
【解决方案2】:
<ScrollView  xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#0000ff" >

<LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <ViewFlipper android:id="@+id/ViewFlipper01"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#aa0000"
        android:layout_gravity="center">  

        <TextView
            android:layout_width="match_parent"
            android:layout_height="50dp">
        </TextView>

</ViewFlipper>
</LinearLayout>
</ScrollView>

这会起作用。

【讨论】:

    【解决方案3】:

    为什么要增加 View Flippers 的高度?视图翻转器取决于您在其中添加的内容或视图。因此,视图翻转器的高度和宽度将始终等于您提供给视图的最大高度/宽度。在您的情况下,它的文本视图因此如果您增加当前视图的高度或添加另一个高度大于当前视图翻转器的 textView。

    【讨论】:

    • 因为viewflipper只占据了一半的屏幕,看起来不太好,因此,我希望它的内容传播并占用更多空间,因为viewflipper必须扩大
    猜你喜欢
    • 2011-06-29
    • 1970-01-01
    • 2011-01-25
    • 2011-11-29
    • 1970-01-01
    • 2011-05-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多