2015-04-27 2 views
1

У меня есть два фрагмента, которые отображаются в зависимости от того, находится ли телефон в альбомном или портретном режиме. однако оба они отображают только первый элемент, но не более того, как EditText или Buttons. Это можно как-то исправить?Фрагментная маска, отображающая только первый элемент (TextView)

pm_layout

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="horizontal" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    > 

    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:text="@string/portrait_message" 
     android:textColor="#000000" 
     android:textSize="100px"/> 


    <EditText 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:hint="Enter First Time"/> 

    <EditText 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:hint="Enter Second Time"/> 

</LinearLayout> 

activity_main.xml

<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" 
    tools:context=".MainActivity" 
    android:orientation="horizontal"> 

    <fragment 
     android:name="com.android.madpracticaltest.LM_Fragment" 
     android:id="@+id/lm_fragment" 
     android:layout_weight="1" 
     android:layout_width="0dp" 
     android:layout_height="match_parent"/> 

    <fragment 
     android:name="com.android.madpracticaltest.PM_Fragment" 
     android:id="@+id/pm_fragment" 
     android:layout_weight="2" 
     android:layout_width="0dp" 
     android:layout_height="match_parent"/> 

    <Button 
     android:id="@+id/button_main" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center_vertical"/> 

</LinearLayout> 
+0

Никогда используйте 'px', используйте' sp' для текста. Кроме того, LM_Fragment выше PM_Fragment с весом 1, что означает, что он занимает больше места. Скорее всего, нет места для всего. –

ответ

3

в pm_layout, у вас есть LinearLayout с orientation="horizontal" и его дети имеют ширину match_parent, так что вы не должны видеть только первый TextView

+0

СПАСИБО! Такая глупая ошибка на моей стороне - будет отмечена как правильная, как только позволяет Stack. –

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