• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Gap between Fragment and TextView in LinearLayout

awhelan

Lurker
Hello,


I am coding an application that is running on a Nexus10. I don't think that matters. I am using Android version 4.4.2.

I am experimenting with using a fragment to display a common group of TextViews that are displayed as the top 3 elements of an Activity that uses a LinearLayout. I am not doing anything formatting outside of the following two LinearLayout XML snippets. In the first (the parent level) I have a fragment and two text views. There is a huge gap that shows up between the fragment and the TextViews. If I remove the android:layout_height="0dp" and android:layout_weight="1" attributes from the fragment tag then the fragment doesn't get displayed at all. Does anyone see why I might be getting this huge gap between the fragment and the two TextViews displayed below it? Thanks!


Here is a the parent (Activity) level Layout. And below it is the fragment specific layout.



[HIGH]
<?xmlversion="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<fragment
android:name="com.srcinc.drphilos.ChemicalNameAndCasNumberFragment"
android:id="@+id/chemical_name_and_cas_number"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
/>
<TextView
android:id="@+id/healthEffectsSummaryLabel"
android:textStyle="bold"
style="@android:style/TextAppearance.Medium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/toxletText"
style="@android:style/TextAppearance.Medium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
[/HIGH]


And following is the fragment specific layout.


[HIGH]
<LinearLayout xmlns:android=http://schemas.android.com/apk/res/android
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/chemicalName"
android:textStyle="bold"
style="@android:style/TextAppearance.Large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/casNumberText"
style="@android:style/TextAppearance.Large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="5dp"
android:background="#DADADA" />
</LinearLayout>
[/HIGH]
 
Back
Top Bottom