滚动型的RelativeLayout内 - Android电子 [英] RelativeLayout inside of ScrollView - Android
问题描述
我改变了我的整个布局从 TableLayout
此活动 RelativeLayout的
因各种原因。我有10个行我想这里面 RelativeLayout的
,但现在我只是想获得一个行工作。之后,1行的工作,我会实施其他9。
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.
有4列在每行中和,现在只有第一列被显示,而不是最后的3下面是code和屏幕截图。 红X是显示第一列。
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>
推荐答案
如果我正确地读它,你指的是这个滚动型:
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>
您的TextView的layout_width设置,当你需要一个WRAP_CONTENT或静态宽度0dip。还您的TextView q1Question未附连到的ImageView q1Image的右侧。当然,除非你想它堆叠ontop的ImageView的的。
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.
这篇关于滚动型的RelativeLayout内 - Android电子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!