android - 如何将 SlidingPaneLayout 的 Listview 部分的宽度设置为 100%

标签 android xml layout android-listview slidingpanelayout

我有一个 SlidingPaneLayout其中左 Pane 是 ListView ,右 Pane 是详细信息 View 。 XML 如下。

问题是——如何使 ListView 的宽度覆盖整个屏幕?正如您在下面看到的(红色箭头),当前宽度并没有一直延伸到屏幕右侧。

enter image description here

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SlidingPaneLayout     xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/sliding_pane_layout"
android:layout_width="fill_parent"
android:layout_height="match_parent" >

<!--
     The first child view becomes the left pane. When the combined
     desired width (expressed using android:layout_width) would
     not fit on-screen at once, the right pane is permitted to
     overlap the left. 
-->

<LinearLayout
    android:id="@+id/ll_left_pane"
    android:layout_width="fill_parent"
    android:layout_height="match_parent"
    android:layout_marginRight="0dp" >

    <ListView
        android:id="@+id/left_pane"
        android:layout_width="fill_parent"
        android:layout_height="match_parent"


        android:layout_marginRight="0dp" />
</LinearLayout>

<!--
     The second child becomes the right (content) pane. In this
     example, android:layout_weight is used to express that this
     pane should grow to consume leftover available space when the
     window is wide enough. This allows the content pane to
     responsively grow in width on larger screens while still
     requiring at least the minimum width expressed by
     android:layout_width.
-->


<!-- Framelayout to display Fragments -->

<FrameLayout
    android:id="@+id/frame_container_slidingpanedetailview"
    android:layout_width="fill_parent"
    android:layout_height="match_parent"
    android:layout_marginLeft="10dp" />

</android.support.v4.widget.SlidingPaneLayout>

最佳答案

在这种情况下, ListView 必然采用固定值,因此更改 ListView 的宽度参数,并在宽度属性中放置一些非常大的值,如 500dp 或 1000dp。

<ListView
        android:id="@+id/left_pane"
        android:layout_width="500dp"
        android:layout_height="match_parent"


        android:layout_marginRight="0dp" />

关于android - 如何将 SlidingPaneLayout 的 Listview 部分的宽度设置为 100%,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26156210/

相关文章:

android - 主进程死后静态变量仍然有效?

安卓APK文件: Re-activate older APK file in Google Play Store

Android 以葡萄牙语登录,但语言环境设置为英语

java - 从 EditText 字段获取输入并保存在变量中

java - ListView 和图像 : I'm going crazy

xml - Symfony2 - 为什么使用 XML 进行设置/配置?

java - 如何在Java中对齐按钮我尝试了一些方法,但在我的代码中不起作用任何线索我要做什么来解决这个问题

layout - 使用backbone.js 构建具有多个 View 的页面

java - 代码似乎阻止 xml 布局在 Android Studio 中显示

layout - 代号 容器中的一个中心组件