-2
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" 
android:layout_height="match_parent" android:orientation="vertical" 
tools:context=".MainActivity"> 

<EditText 
    android:layout_marginTop="5dp" 
    android:layout_width="match_parent" 
    android:layout_height="50dp" 
    android:background="@drawable/location_edittext" 
    android:id="@+id/locationEditext" 
    android:textSize="15sp" 
    android:textColor="#999" 
    android:paddingLeft="15dp" /> 


<com.example.ravi_gupta.slider.ViewPagerCustomDuration 
    android:layout_width="wrap_content" 
    android:layout_height="0dp" 
    android:id="@+id/viewPager" 
    android:scrollbarStyle="outsideOverlay" 
    android:layout_weight="0.5"> 
</com.example.ravi_gupta.slider.ViewPagerCustomDuration> 

<ListView 
    android:layout_weight="0.50" 
    android:layout_below="@+id/viewPager" 
    android:layout_marginTop="2dp" 
    android:layout_width="match_parent" 
    android:layout_height="45dp" 
    android:id="@+id/shopListview" /> 

安卓:讓列表視圖全屏

這是我在activity.main代碼我,我要的是,當我滾動列表視圖它需要在佈局中的所有空間隱藏viewpager和editext當我向後滾動顯示它們,我不知道這是怎麼可能的,我應該使用相對佈局或其他方法

+0

你已經給列表視圖和高度賦予權重,爲什麼呢? – frost

+0

我試圖通過重量顯示listview的高度ot,但這種解決方案似乎不起作用 – Ravi

+0

如果你給重量,那麼不需要高度 – frost

回答

1

你不能簡單地依賴於佈局。修改您的代碼並查看setVisibility方法@setVisibility of View。 例如,如果該方法被設置爲EditText UI的GONE,則該UI完全隱藏,就好像它從未顯示過一樣。當然,在適當的時候你應該把它設置爲VISIBLE