Android弹出窗口自动调整大小

时间:2014-04-07 20:38:27

标签: android android-layout circular-dependency

今天我面临着android中布局的问题。

这是我的目标: 我想要一个带有标题的弹出窗口,一个包含scrollView(如果是大数据)和一个按钮的主体。

这就是我的布局在大行中的样子:

<RelativeLayout
    android:id="@+id/popup_layout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:background="#FF0000">

    <TextView
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="20dp"
        android:text="Title"/>

    <ScrollView
        android:id="@+id/body_scrollview"
        android:layout_width="wrap_content"//To permit the scrollview to resize depending of the data amount
        android:layout_height="wrap_content"
        android:layout_below="@id/title"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="10dp">

        <TextView
            android:id="@+id/body_txt"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="My very long sentence which may take all the screen size and maybe more"/>
    </ScrollView>

    <Button
        android:id="@+id/confirm"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_below="@id/body_scrollview">
    </Button>
</RelativeLayout>

如果文字很短,那么没问题,按钮仍然可见,但如果文字很大(我的意思是大于屏幕可以支持的那个),按钮就会消失。

我可以使用按钮进行底部对齐,然后将上面的属性放在scrollView中,但这会导致弹出窗口始终占用所有高度(即使文本非常小),这不是我想要的

我知道应该怎么做吗?

先谢谢你。

0 个答案:

没有答案