如何在activity的特定位置打开列表视图?
How to open List view in a specific place of activity?
我想打开列表视图,从屏幕底部到屏幕中间几乎没有高度。我不知道该怎么做。我只是想到它只能通过片段来完成,我不知道如何在我当前的 activity 和 xml 中使用它我想要的如下图所示:
我希望我的问题很清楚。我知道如何实现列表视图,但我不知道如何以我想要的方式实现它(我的意思是在不干扰其他视图的情况下出现和消失)。此列表应覆盖其他视图。
编辑
including my Xml File so that if you can see what I have done in design
<?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>
有什么建议吗?源代码将不胜感激。谢谢
将您的列表视图放在单独的空白处 activity 并在清单中将 activity 的主题作为对话框
<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 的大小 activity 并添加边距以适合您需要的位置
我给你样品。你必须需要修改。有疑问就问
<?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。
我想打开列表视图,从屏幕底部到屏幕中间几乎没有高度。我不知道该怎么做。我只是想到它只能通过片段来完成,我不知道如何在我当前的 activity 和 xml 中使用它我想要的如下图所示:
我希望我的问题很清楚。我知道如何实现列表视图,但我不知道如何以我想要的方式实现它(我的意思是在不干扰其他视图的情况下出现和消失)。此列表应覆盖其他视图。
编辑
including my Xml File so that if you can see what I have done in design
<?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>
有什么建议吗?源代码将不胜感激。谢谢
将您的列表视图放在单独的空白处 activity 并在清单中将 activity 的主题作为对话框
<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 的大小 activity 并添加边距以适合您需要的位置
我给你样品。你必须需要修改。有疑问就问
<?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。