Search code examples
androidandroid-layoutandroid-listviewandroid-viewpagerandroid-relativelayout

Android : Making Listview full screen


<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" />

This is my code in activity.main I, all I want is that when I scroll the listview it take all the space in the layout hiding viewpager and editext and when I scroll back it shows both of them, I don't know how this can be possible, Either I should use Relative layout or some Other method


Solution

  • You cannot simply depend on the layout. Modify your code and look at setVisibility method @ setVisibility of View. For example, if that method is set to GONE to EditText UI, then that UI is completely hidden as if it was never shown. And then of course, you should set it to VISIBLE when appropriate.