开发者

table layout TextViews show text vertically vs horizontally wether they are in or out of focus

I am fairly new to eclipse and java and android dev. I have spent hours searching for an answer to this dilemma to no avail. I have a table on 3 activities of my app that consist of vertical or horizontal alteration of textViews and editText elements ie: t,e t,e t,e or tttt,eeee.

Everything looks good in eclipse i have double checked layout weight and gravity but when these activities run on emulator the text in each textView will appear vertical until i bring focus to the parent table by selecting a editText element within the same table. Once i do this the text returns to the correct horizontal fashion i originally placed it in but again reverses if focus is taken away from the table? can anyone help me?

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/FireScreen">
    <ScrollView 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/diamondplate"
    android:orientation="vertical">

<TextView 
    android:background="@drawable/buttonfade" 
    android:id="@+id/FireScreenTitle" 
    android:layout_alignParentTop="true" 
    android:layout_height="40dip" 
    android:layout_width="150dip" 
    android:textStyle="bold" 
    android:text="FIRE INFO"
    android:textSize="21sp" 
    android:textColor="#FF0000"
    android:gravity="center">
    </TextView>
    <TableLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_below="@+id/FireScreenTitle"
    android:layout_height="wrap_content"
    android:layout_margin="5dip"
    android:id="@+id/FIfiretable">
    <TableRow>
<TextView   
android:id="@+id/FIfiretype" 
android:text="Fire Type" 
android:layout_width="0dip" 
android:layout_height="40dip"
android:layout_marginBottom="5dip" 
android:layout_marginRight="5dip" 
android:textStyle="bold"
android:textSize="12sp"
android:textColor="#ffffff"
android:background="@drawable/buttonfade"
android:gravity="center" 
android:layout_weight="1">
</TextView>
<Spinner
android:id="@+id/FItypespin"
android:layout_width="0dip" 
android:layout_height="40dip"
android:layout_marginBottom="5dip"
android:layout_weight="1">
</Spinner>
    </TableRow>
    <TableRow>
<TextView   
android:id="@+id/FIareatype" 
android:text="Fire Area" 
android:layout_width="0dip" 
android:layout_height="40dip"
android:layout_marginBottom="5dip" 
android:layout_marginRight="5dip" 
android:textStyle="bold"
android:textSize="12sp"
android:textColor="#ffffff"
android:background="@drawable/buttonfade"
android:gravity="center" 
android:layout_weight="1">
</TextView>
<Spinner
android:id="@+id/FIareaspin"
android:layout_width="0dip" 
android:layout_height="40dip"
android:layout_marginBottom="5dip"
android:layout_weight="1">
</Spinner>
    </TableRow>
    <TableRow>
<TextView   
android:id="@+id/FIactiontype" 
android:text="Action Taken" 
android:layout_width="0dip" 
android:layout_height="40dip"
android:layout_marginBottom="5dip" 
android:layout_marginRight="5dip" 
android:textStyle="bold"
android:textSize="12sp"
android:textColor="#ffffff"
android:background="@drawable/buttonfade"
android:gravity="center" 
android:layout_weight="1">
</TextView>
<Spinner
android:id="@+id/FIactionspin"
android:layout_width="0dip" 
android:layout_height="40dip"
android:layout_marginBottom="5dip"
android:layout_weight="1">
</Spinner>
    </TableRow>
    </TableLayout>

    <TableLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_below="@+id/FIfiretable"
    android:layout_height="wrap_content"
    android:layout_margin="5dip"
    android:id="@+id/FIcalltable">
    <TableRow>
<TextView 
android:id="@+id/FIinvolved" 
android:text="% Involved" 
android:layout_width="0dip" 
android:layout_height="35dip"
android:layout_marginBottom="5dip" 
android:layout_marginRight="5dip" 
android:textStyle="bold"
android:textSize="12sp"
android:textColor="#ffffff"
android:background="@drawable/buttonfade"
android:gravity="center"
android:layout_weight="1">
</TextView>
<TextView 
android:id="@+id/FIwater" 
android:text="H2O Gal." 
android:layout_width="0dip" 
android:layout_height="35dip"
android:layout_marginBottom="5dip" 
android:textStyle="bold"
android:textColor="#ffffff"
android:background="@drawable/buttonfade"
android:g开发者_如何学编程ravity="center" 
android:layout_weight="1"
android:textSize="12sp">
</TextView>
</TableRow>
<TableRow>
<EditText 
android:text="" 
android:layout_width="0dip" 
android:layout_height="35dip"
android:layout_marginBottom="5dip" 
android:layout_marginRight="5dip"
android:numeric="integer" 
android:id="@+id/FIinvolvedtext"
android:textSize="12sp" 
android:layout_weight="1">
</EditText>
    <EditText 
android:text="" 
android:layout_width="0dip" 
android:layout_height="35dip"
android:layout_marginBottom="5dip" 
android:numeric="integer" 
android:id="@+id/FIwatertext"
android:textSize="12sp" 
android:layout_weight="1">
</EditText>
</TableRow>
<TableRow>
<TextView 
android:id="@+id/FIfoam" 
android:text="Foam Gal." 
android:layout_width="0dip" 
android:layout_height="35dip"
android:layout_marginBottom="5dip"
android:layout_marginRight="5dip" 
android:textStyle="bold"
android:textColor="#ffffff"
android:background="@drawable/buttonfade"
android:gravity="center" 
android:layout_weight="1"
android:textSize="12sp">
</TextView>
<TextView 
android:id="@+id/FIacres" 
android:text="Acres" 
android:layout_width="0dip" 
android:layout_height="35dip"
android:layout_marginBottom="5dip" 
android:textStyle="bold"
android:textColor="#ffffff"
android:background="@drawable/buttonfade"
android:gravity="center" 
android:layout_weight="1"
android:textSize="12sp">
</TextView>
</TableRow>
<TableRow>
<EditText 
android:text="" 
android:layout_width="0dip" 
android:layout_height="35dip"
android:layout_marginBottom="5dip"
android:layout_marginRight="5dip" 
android:numeric="integer" 
android:id="@+id/FIfoamtext"
android:textSize="12sp" 
android:layout_weight="1">
</EditText>
    <EditText 
android:text="" 
android:layout_width="0dip" 
android:layout_height="35dip"
android:layout_marginBottom="5dip"
android:numeric="integer" 
android:id="@+id/FIacrestext"
android:textSize="12sp" 
android:layout_weight="1">
</EditText>
    </TableRow>
    <TableRow>
    <TextView 
android:id="@+id/FIcasualties" 
android:text="Casualties" 
android:layout_width="0dip" 
android:layout_height="35dip"
android:layout_marginRight="5dip"
android:layout_marginBottom="5dip" 
android:textStyle="bold"
android:textColor="#ffffff"
android:background="@drawable/buttonfade"
android:gravity="center" 
android:layout_weight="1"
android:textSize="12sp">
</TextView>
<TextView 
android:id="@+id/FIfatalities" 
android:text="Fatalities" 
android:layout_width="0dip" 
android:layout_height="35dip"
android:layout_marginBottom="5dip" 
android:textStyle="bold"
android:textColor="#ffffff"
android:background="@drawable/buttonfade"
android:gravity="center" 
android:layout_weight="1"
android:textSize="12sp">
</TextView>
    </TableRow>
    <TableRow>
    <EditText 
android:text="" 
android:layout_width="0dip" 
android:layout_height="35dip"
android:layout_marginBottom="5dip"
android:layout_marginRight="5dip" 
android:numeric="integer" 
android:id="@+id/FIcasualtiestext"
android:textSize="12sp" 
android:layout_weight="1">
</EditText>
<EditText 
android:text="" 
android:layout_width="0dip" 
android:layout_height="35dip"
android:layout_marginBottom="5dip"
android:numeric="integer" 
android:id="@+id/FIfatalitiestext"
android:textSize="12sp" 
android:layout_weight="1">
</EditText>
</TableRow>
    </TableLayout>

    <TextView 
    android:id="@+id/FInotes"
    android:textColor="#ffffff"
    android:background="@drawable/buttonfade"
    android:layout_width="100dip"
    android:textStyle="bold" 
    android:text="Notes"
    android:layout_alignLeft="@+id/FIcalltable"
    android:layout_below="@+id/FIcalltable"
    android:layout_height="35dip"
    android:gravity="center">
    </TextView>
    <EditText 
    android:id="@+id/FInotestext" 
    android:text="Additional Information:"
    android:textSize="12sp" 
    android:layout_width="fill_parent" 
    android:layout_below="@+id/FInotes"
    android:layout_alignLeft="@+id/FInotes" 
    android:layout_height="200dip" 
    android:gravity="top"
    android:layout_marginRight="5dip"
    android:layout_marginBottom="5dip"
    android:inputType="textMultiLine"   
    android:lines="5">
    </EditText>
    </RelativeLayout>
    </ScrollView>

    <TableLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_alignParentBottom="true"
    android:layout_height="50dip"
    android:background="@drawable/fire_thumb"
    android:id="@+id/FImenutable">
    <TableRow>
    <Button 
    android:id="@+id/FIUnitsStart"
    android:background="@drawable/button2"
    android:layout_width="0dip"
    android:textStyle="bold"
    android:textSize="15sp" 
    android:text="UNITS"
    android:textColor="#ff0000"
    android:layout_height="fill_parent"
    android:gravity="center"
    android:hapticFeedbackEnabled="true"
    android:layout_weight="1"/>
    <Button 
    android:id="@+id/FIMainResume"
    android:background="@drawable/button2"
    android:textStyle="bold"
    android:textSize="15sp" 
    android:text="MAIN"
    android:textColor="#ffffff"
    android:layout_height="fill_parent"
    android:gravity="center"
    android:hapticFeedbackEnabled="true" 
    android:layout_width="0dip" 
    android:layout_weight="1"/>
    </TableRow>

    </TableLayout> 
    </RelativeLayout>


HAHA!!! I have figured it out! lol I had two table layouts within the same parent layout and therefore when one was given process focus over the other.... text alteration. I fixed this by placing table2 within another layout:) I.E.:

Old Way:

    <LinearLayout>
        <ScrollView>
        <RelativeLayout>
            <TableLayout1>
            <TableLayout1>

            <TableLayout2>
            <TableLayout2>
        <RelativeLayout>
        <ScrollView>
    <LinearLayout>

New (successful) Way:

    <LinearLayout>
        <ScrollView>
        <RelativeLayout>
            <TableLayout1>
            <TableLayout1>

            <LinearLayout2>
                <TableLayout2>
                <TableLayout2>
            <LinearLayout2>
        <RelativeLayout>
        <ScrollView>
    <LinearLayout>

Now neither TableLayout is robbing focus from the other in the same layout . . . I am not sure why I had to do this but hey it works now lol

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜