Reputation: 960
<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"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
<EditText
android:layout_marginTop="5dp"
android:layout_width="match_parent"
android:layout_height="45dp"
android:background="@drawable/location_edittext"
android:id="@+id/locationEditext"
android:textSize="15sp"
android:textColor="#999"
android:paddingLeft="15dp"
android:text="Galli No 1, U Block, DLF Phase 3, Sector 24"
android:hint="Galli No 1, U Block, DLF Phase 3, Sector 24" />
<com.example.ravi_gupta.slider.ViewPagerCustomDuration
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/viewPager"
android:scrollbarStyle="outsideOverlay">
</com.example.ravi_gupta.slider.ViewPagerCustomDuration>
<EditText
android:layout_below="@+id/viewPager"
android:layout_marginTop="5dp"
android:layout_width="match_parent"
android:layout_height="45dp"
android:background="@drawable/location_edittext"
android:id="@+id/locationEditext9"
android:textSize="15sp"
android:textColor="#999"
android:paddingLeft="15dp"
android:text="Galli No 1, U Block, DLF Phase 3, Sector 24"
android:hint="Galli No 1, U Block, DLF Phase 3, Sector 24"/>
This is my linear layout, my problem is that last editText is not showing as my view pager is taking so much space and hiding last edittext I dont know why?
Upvotes: 0
Views: 154
Reputation: 960
Finally, I got the solution of the problem using Relative and Linear Layout
<RelativeLayout 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"
android:text="Galli No 1, U Block, DLF Phase 3, Sector 24"
android:hint="Galli No 1, U Block, DLF Phase 3, Sector 24" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/locationEditext"
android:orientation="vertical">
<com.example.ravi_gupta.slider.ViewPagerCustomDuration
android:layout_width="match_parent"
android:layout_height="220dp"
android:id="@+id/viewPager"
android:scrollbarStyle="outsideOverlay">
</com.example.ravi_gupta.slider.ViewPagerCustomDuration>
<ListView
android:layout_weight="1"
android:layout_marginTop="2dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/shopListview" />
</LinearLayout>
Upvotes: 0
Reputation: 2364
As Viktor mentioned in his comment, you may just want to use a RelativeLayout. But if you want to use a LinearLayout you can utilize the "layout_weight"
xml attribute
Set all the layout_height
attributes to 0dp and use the layout_weight
as a percentage to specifiy the height each view takes on the screen. For example:
<EditText
android:layout_marginTop="5dp"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.2"
android:background="@drawable/location_edittext"
android:id="@+id/locationEditext"
android:textSize="15sp"
android:textColor="#999"
android:paddingLeft="15dp"
android:text="Galli No 1, U Block, DLF Phase 3, Sector 24"
android:hint="Galli No 1, U Block, DLF Phase 3, Sector 24" />
<com.example.ravi_gupta.slider.ViewPagerCustomDuration
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="0.6"
android:id="@+id/viewPager"
android:scrollbarStyle="outsideOverlay">
</com.example.ravi_gupta.slider.ViewPagerCustomDuration>
<EditText
android:layout_below="@+id/viewPager"
android:layout_marginTop="5dp"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.2"
android:background="@drawable/location_edittext"
android:id="@+id/locationEditext9"
android:textSize="15sp"
android:textColor="#999"
android:paddingLeft="15dp"
android:text="Galli No 1, U Block, DLF Phase 3, Sector 24"
android:hint="Galli No 1, U Block, DLF Phase 3, Sector 24"/>
This implementation will have your EditTexts taking up about 20% of the screen each and the custom ViewPager taking up 60%. Change these around as desired.
Upvotes: 1
Reputation: 3868
First off, android:layout_below="@+id/viewPager"
won't work since you are in a LinearLayout
.
Then, I don't know what ViewPagerCustomDuration
does, but if you are trying to put the EditText
at the bottom of the screen, then you should use the weights.
Try to assign android:layout_height="wrap_content"
the the two EditText
and for the ViewPager
use
android:layout_height="0dp"
android:layout_weight="1"
Hope it helps.
Upvotes: 1