0
<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没有显示我的观点寻呼机正在采取这么大的空间和隐藏最后的EditText我不知道为什么?

+0

所以在您的自定义ViewPager,特别是在onMeasure或onLayout方法的问题。您可以使用相对布局避免此问题。 –

+0

我已经尝试过,但无法在正确的解决方案中达到 – Ravi

回答

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> 

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

正如Viktor在他的评论中提到的,您可能只是想使用RelativeLayout。但是,如果你想使用的LinearLayout您可以利用"layout_weight" XML属性

设置所有layout_height属性0dp并使用layout_weight,以百分数表示specifiy高度每个视图需要在屏幕上。例如:

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

此实现将使您的EditText占用大约20%的屏幕,并且自定义ViewPager占用60%。根据需要改变这些。

+0

重量似乎很好地工作,但是当我点击edittext时,我的视图寻呼机变得很小为什么我应该使用相对布局,那么该怎么做? – Ravi