如何在特定的活动场所打开列表视图?

时间:2015-05-15 12:07:32

标签: android listview android-activity fragment

我想从屏幕底部打开List视图到屏幕中间的几乎高点。我不知道该怎么做。我只是想到它只能通过片段完成,我不知道如何在我当前的活动和xml中使用它我想要的如下图所示:

enter image description here

我希望我的问题很清楚。我知道如何实现列表视图,但我不知道如何以我想要的方式实现它(我的意思是出现并消失而不顾其他观点)。此列表应覆盖其他视图。

修改

  

包括我的Xml文件,以便您可以看到我在设计中所做的事情

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


<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
   >

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:contentDescription="content_desc_overlay"
        android:src="@drawable/ic_launcher"
        android:id="@+id/img_view"

        />


    <ImageView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:id="@+id/iv_overlay"
        android:src="@drawable/doom"
        android:scaleType="matrix"

        />

</FrameLayout>


    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Open List"
        android:id="@+id/btn_screenshot"
        android:layout_gravity="right|top"
        />

</RelativeLayout>

有什么建议吗?源代码将不胜感激。谢谢

2 个答案:

答案 0 :(得分:1)

将列表视图放在单独的空白活动中,并在清单中将活动主题作为对话框

<activity
        android:name=".ui.activities.EditSignatureActivity"
        android:label="@string/title_activity_edit_signature"
        android:theme="@android:style/Theme.Holo.Light.Dialog" >
    </activity>

点击打开列表按钮开始新意图:

public void openListButton_OnClick(View v) {
    Intent intent = new Intent(HomeActivity.this, List.class);
    startActivity(intent);
}
不要忘记调整新的listView活动的大小,只要你想要它的尺寸,并添加边距以适应你需要的位置

答案 1 :(得分:0)

我会给你样品。你必须要修改。询问是否有疑问

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

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" 
        android:layout_marginTop="50dp"
        android:id="@+id/top_row">

        <LinearLayout
            android:layout_width="0dip"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:orientation="horizontal" >

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:text="Text A" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="0dip"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:orientation="horizontal" >

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:text="Text B" />
        </LinearLayout>
    </LinearLayout>

    <ListView 
        android:id="@+id/listView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/top_row"
        android:layout_marginBottom="15dp"
        android:layout_marginLeft="30dp"
        android:layout_marginRight="30dp"
        android:layout_marginTop="15dp"></ListView>

</RelativeLayout>

注意:您需要使用数据加载listView。