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

Android: EditText не показывает

Это моя линейная планировка, моя проблема заключается в том, что последний EditText не показывается, как мой взгляд пейджер занимает так много места и скрывается последним EditText я не знаю, почему?

+0

Так что проблема в пользовательских ViewPager, особенно в onMeasure или OnLayout методов. Вы можете избежать этой проблемы, используя относительный макет. –

+0

Я пробовал, но не могу достичь правильного решения. – Ravi

ответ

0

Наконец, я получил решение задачи с использованием относительной и 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> 

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

Как отметил Виктор в своем комментарии, вы можете просто использовать 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"/> 

Эта реализация будет иметь ваши EditTexts занимают около 20% экрана каждого и обычая ViewPager занимают 60%. Измените их по желанию.

+0

весов, кажется, работает отлично, но когда я нажимаю на edittext, мой пейджер просмотра становится маленьким, почему, следует ли использовать относительную компоновку, тогда как? – Ravi

Смежные вопросы