Android 如何在活动的特定位置打开列表视图?
我想打开列表视图,从屏幕底部到屏幕中间几乎不高的位置。我不知道怎么做。我刚刚想到它只能由片段完成,我不知道如何在我当前的活动中使用它,我想要的xml如下图所示: 我希望我的问题很清楚。我知道如何实现列表视图,但我不知道如何以我想要的方式实现它(我的意思是在不干扰其他视图的情况下出现和消失)。此列表应覆盖其他视图 编辑 包括我的Xml文件,以便您可以看到我在设计中所做的工作Android 如何在活动的特定位置打开列表视图?,android,listview,android-activity,fragment,Android,Listview,Android Activity,Fragment,我想打开列表视图,从屏幕底部到屏幕中间几乎不高的位置。我不知道怎么做。我刚刚想到它只能由片段完成,我不知道如何在我当前的活动中使用它,我想要的xml如下图所示: 我希望我的问题很清楚。我知道如何实现列表视图,但我不知道如何以我想要的方式实现它(我的意思是在不干扰其他视图的情况下出现和消失)。此列表应覆盖其他视图 编辑 包括我的Xml文件,以便您可以看到我在设计中所做的工作 有什么建议吗?源代码将不胜感激。谢谢将您的列表视图放在一个单独的空白活动中,并将活动主题作为对话框放在清单中 <
有什么建议吗?源代码将不胜感激。谢谢将您的列表视图放在一个单独的空白活动中,并将活动主题作为对话框放在清单中
<activity
android:name=".ui.activities.EditSignatureActivity"
android:label="@string/title_activity_edit_signature"
android:theme="@android:style/Theme.Holo.Light.Dialog" >
</activity>
不要忘记根据需要调整新listView活动的大小,并添加边距以适合所需的位置。我将为您提供示例。您必须修改。询问是否有任何疑问
<?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。这是基于xml设计的。所以你需要向我们展示你的xml文件。等等,我包括了这个,但它是simple@Amsheer现在看一看它是透明的吗?你是说listview的背景吗??如果是,您可以简单地将背景设置为烟雾色,如下所示
android:background=“#88c2c4c9”
前88个用于透明度,其余用于颜色,您可以根据需要进行更改,但给出以下错误。java.lang.IllegalStateException:您需要在此活动中使用Theme.AppCompat主题(或子代)。是的,将“back”活动中的应用程序主题样式更改为“res-->values-->StylesId”,您可以在“res-->values-->StylesId”下找到它。您在新活动中扩展活动,而不是ActionBarActivity??
public void openListButton_OnClick(View v) {
Intent intent = new Intent(HomeActivity.this, List.class);
startActivity(intent);
}
<?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>