2016-02-29 85 views
-1

的ListView图片如何在ListView中设置不可见区域?

enter image description here

嗨。我在我的Android应用程序中使用ListView。 我想设置我的listView像上面的图像。

应用程序用户只能看到LEFT和CENTER区域。 我想在RIGHT区域设置一些组件,但是这个区域一定不可见。

我该怎么做?

这是我目前的布局XML代码:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="horizontal" 
android:padding="8dp" > 

<!-- LEFT AREA START (VISIBLE) --> 
<LinearLayout 
    android:layout_width="0dp" 
    android:layout_height="match_parent" 
    android:layout_marginRight="5dp" 
    android:layout_weight="1" 
    android:orientation="vertical" > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" > 


     <ImageView 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="2" 
      android:gravity="center" 
      android:src="@drawable/ic_launcher" /> 

     <Button 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="1" 
      android:gravity="center" 
      /> 

    </LinearLayout> 
</LinearLayout> 
<!-- LEFT AREA END --> 


<!-- CENTER AREA (VISIBLE) --> 
<LinearLayout 
    android:layout_width="0dp" 
    android:layout_height="match_parent" 
    android:layout_weight="2" 
    android:orientation="vertical" > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:orientation="horizontal" > 

     <Button 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_margin="2dp" 
      android:layout_weight="2" 
      /> 

     <Button 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_margin="2dp" 
      android:layout_weight="2" 
      /> 
    </LinearLayout> 


    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:orientation="horizontal" > 

     <Button 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_margin="2dp" 
      android:layout_weight="1" 
      /> 

     <Button 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_margin="2dp" 
      android:layout_weight="1" 
      /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:orientation="horizontal" > 

     <Button 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_margin="2dp" 
      android:layout_weight="1" 
      /> 

     <Button 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_margin="2dp" 
      android:layout_weight="1" 
      /> 
    </LinearLayout> 

</LinearLayout> 
<!-- CENTER AREA END --> 


<!-- RIGHT AREA START (INVISIBLE) --> 
    <!-- I don't know what to do --> 
<!-- RIGHT AREA END --> 

+0

将您的右侧区域布局设置为android:visibility =“gone” –

回答

2

你可以试试这个元素RIGHT布局:

android:visibility="gone" 

关于此元素:

这视图是不可见的,它不需要任何s步伐布局 目的

0

有看不见的小部件的一个属性,通过它们可占用空间,但控制没有显示支票下面的代码

<!-- LEFT AREA START (VISIBLE) --> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="horizontal" > 

    <LinearLayout 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:layout_weight="0.33" 
     android:orientation="vertical" > 

     <ImageView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:gravity="center" 
      android:src="@drawable/ic_launcher" /> 

     <Button 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:gravity="center" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:layout_weight="0.33" 
     android:orientation="vertical" > 

     <ImageView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:gravity="center" 
      android:src="@drawable/ic_launcher" /> 

     <Button 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:gravity="center" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:layout_weight="0.33" 
     android:visibility="invisible" 
     android:orientation="vertical" > 


    </LinearLayout> 
</LinearLayout> 

0

你可以在布局xml文件中的任何视图元素上设置visibility="gone",以使其从用户的视线中消失。

0

我认为您正在寻找滑动布局,一旦按钮被点击或执行任何其他事件,就会显示滑动布局,直到比布局隐藏和其他布局将占用设备的整个空间。

您应该检查这个SlidingPaneLayout

这里是SlidingPaneLayout很好的演示。

Link 1
Link 1

enter image description here

你可以把它从右侧获得所需输出滑动。

1

您可以在右侧区域设置android:visibility =“gone”

相关问题