<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"/>
这是我的线性布局,我的问题是最后的editText没有显示,因为我的视图寻呼机占用了太多空间并隐藏了最后一个edittext我不知道为什么?
答案 0 :(得分:1)
首先,android:layout_below="@+id/viewPager"
因为您身处LinearLayout
而无法工作。
然后,我不知道ViewPagerCustomDuration
做了什么,但是如果你试图将EditText
放在屏幕的底部,那么你应该使用权重。
尝试分配android:layout_height="wrap_content"
两个EditText
和ViewPager
使用
android:layout_height="0dp"
android:layout_weight="1"
希望它有所帮助。
答案 1 :(得分:1)
正如Viktor在评论中提到的,你可能只想使用RelativeLayout。但是如果你想使用LinearLayout,你可以使用"layout_weight"
xml属性
将所有layout_height
属性设置为0dp,并使用layout_weight
作为百分比来指定每个视图在屏幕上显示的高度。例如:
<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"/>
此实现将使您的EditTexts占据屏幕的大约20%,自定义ViewPager占用60%。根据需要更改这些。
答案 2 :(得分:0)
最后,我使用相对和线性布局
得到了问题的解决方案<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>