Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am changing my whole layout for this activity from a TableLayout to RelativeLayout for various reasons. I have 10 "rows" I want inside of this RelativeLayout but right now I am just trying to get one row working. After that 1 row is working, I will implement the other 9.

There are 4 columns in each row and right now only the first column is displaying and not the last 3. Below is the code and screenshot. The "red x" is the first column that is displaying.

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/tableLayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:stretchColumns="1"
    android:shrinkColumns="0"
    android:orientation="vertical"
    android:paddingLeft="16dp"
    android:paddingRight="16dp"
    android:paddingTop="70dp"
    android:paddingBottom="70dp"
    android:background="@drawable/scroll" >    

    <TableLayout
        android:layout_width="match_parent"
        android:layout_height="0dip"
        android:layout_weight="20" >

        <TableRow
            android:id="@+id/header"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="1" >

            <TextView
                android:id="@+id/category"
                android:layout_height="wrap_content"
                android:layout_width="0px"
                android:layout_weight="1"
                android:textStyle="bold"
                android:textSize="15sp"
                android:paddingTop="10dp"
                android:gravity="center_horizontal" />

            <TableLayout
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight="1" >

                <TableRow
                    android:layout_width="0dip"
                    android:layout_height="wrap_content"
                    android:layout_weight="1" >

                    <TextView
                        android:id="@+id/points"
                        android:layout_width="0dip"
                        android:layout_height="wrap_content"
                        android:layout_weight=".25"
                        android:textSize="9sp"
                        android:gravity="left" 
                        android:textStyle="bold" />
                </TableRow>

                <TableRow
                    android:layout_width="0dip"
                    android:layout_height="wrap_content"
                    android:layout_weight="1" >

                    <TextView
                        android:id="@+id/percentage"
                        android:layout_width="0dip"
                        android:layout_height="wrap_content"
                        android:layout_weight=".3"
                        android:textSize="9sp"
                        android:gravity="left"
                        android:textStyle="bold" />
                </TableRow>

                <TableRow
                    android:layout_width="0dip"
                    android:layout_height="wrap_content"
                    android:layout_weight="1" >

                    <TextView
                        android:id="@+id/total_score"
                        android:layout_width="0dip"
                        android:layout_height="wrap_content"
                        android:layout_weight=".45"
                        android:textSize="9sp"
                        android:gravity="left"
                        android:textStyle="bold" />
                </TableRow>
            </TableLayout>
        </TableRow>

        <View 
            android:layout_width="fill_parent"
            android:layout_height="1dp"       
            android:background="#000001" />

        <TableRow
            android:id="@+id/row3"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="1" >

            <TextView
                android:id="@+id/imageColumn"
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight="0" />

            <TextView
                android:id="@+id/questionColumn"
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight=".45"
                android:textSize="10sp"
                android:textStyle="bold|italic"
                android:gravity="center_vertical" />

            <TextView
                android:id="@+id/answerColumn"
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight=".3"
                android:textSize="10sp"
                android:textStyle="bold|italic"
                android:gravity="center_vertical" />

            <TextView
                android:id="@+id/verseColumn"
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight=".25"
                android:textSize="10sp"
                android:textStyle="bold|italic"
                android:gravity="center_vertical" />
        </TableRow>
    </TableLayout>

    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="65"
        android:fillViewport="true" >

        <RelativeLayout 
            android:layout_width="fill_parent"   
            android:layout_height="wrap_content"> 

            <ImageView 
                android:id="@+id/q1Image"
                android:layout_width="10dp"
                android:layout_height="10dp"  /> 

            <TextView 
                android:id="@+id/q1Question"
                android:layout_width="0dip"
                android:layout_height="wrap_content" /> 

            <TextView 
                android:id="@+id/q1Answer"
                android:layout_width="0dip"
                android:layout_height="wrap_content"   
                android:layout_toRightOf="@id/q1Question"  /> 

            <TextView 
                android:id="@+id/q1Verse"
                android:layout_width="0dip"
                android:layout_height="wrap_content"   
                android:layout_toRightOf="@id/q1Answer"  /> 
        </RelativeLayout>
    </ScrollView>

    <TableLayout
        android:layout_width="match_parent"
        android:layout_height="0dip"
        android:layout_weight="15" >

        <TableRow
            android:id="@+id/row14"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:stretchColumns="0,1" >

            <Button 
                android:id="@+id/mainmenuBtn"
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:textSize="7sp" />

            <Button 
                android:id="@+id/highscoresBtn"
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:textSize="7sp" />
            <Button 
                android:id="@+id/playBtn"
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:textSize="7sp" />
        </TableRow>
    </TableLayout>
</LinearLayout>

enter image description here

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
111 views
Welcome To Ask or Share your Answers For Others

1 Answer

If I read it correctly and you are referring to this ScrollView:

<ScrollView
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="65"
        android:fillViewport="true" >

        <RelativeLayout 
            android:layout_width="fill_parent"   
            android:layout_height="wrap_content"> 

            <ImageView 
                android:id="@+id/q1Image"
                android:layout_width="10dp"
                android:layout_height="10dp"  /> 

            <TextView 
                android:id="@+id/q1Question"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@id/q1Image"   /> 

            <TextView 
                android:id="@+id/q1Answer"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"   
                android:layout_toRightOf="@id/q1Question"  /> 

            <TextView 
                android:id="@+id/q1Verse"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"   
                android:layout_toRightOf="@id/q1Answer"  /> 
        </RelativeLayout>
    </ScrollView>

Your TextView's layout_width was set to 0dip when you need a wrap_content or static width. Also your TextView q1Question was not attached to the right of ImageView q1Image. Unless of course you wanted it stacked ontop of the ImageView.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...