开发者

Fitting all of the views onto one table row

I'm trying to put a TextView into my TableView so that it doesn't push the spinner box and the other TextView off of the screen. I've tried changing the layout_width, yet that has not worked. I have also tried changing the layout_width of the TableRow, but that is not working, either. So how can I fit the text of the left-most textView in the row?

<TableLayout android:id="@+id/abilityScoreTable"
android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android" android:padding="0dip">
    <TextView android:layout_height="wrap_content"     android:textAppearance="?android:attr/textAppearanceLarge" android:layout_width="wrap_content" android:gravity="center" android:textSize="30dip" android:id="@+id/abilityScoreBannerText" android:text="Ability Scores"></TextView>
    <TableRow android:layout_width="wrap_content" android:gravity="center" android:id="@+id/tableRow1" android:layout_height="wrap_content">
       <TextView android:text="zero" android:id="@+id/StrengthBonusText" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
        <Spinner android:id="@+id/StrengthSpinner" android:layout_width="10px" android:layout_height="wrap_content" android:entries="@array/string_ability_scores"></Spinner>
        <TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge" android:id="@+id/StrengthTextView" android:text="Strength"
android:textSize="30dip"></TextView>
    </TableRow>
    <TableRow android:layout_height="wrap_content"
android:layout_width="wrap_content" android:id="@+id/tableRow2" android:gravity="center">
        <Spinner android:layout_height="wrap_content" android:layout_width="wrap_content"
android:id="@+id/dexteritySpinner" android:entries="@array/string_ability_scores"></Spinner>
        <TextView android:id="@+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:text="Dexterity" android:textSize="30dip"></TextView>
    </TableRow>
    <TableRow android:layout_width="wrap_content" android:layout_height="wrap_content"
android:entries="@array/string_ability_scores" android:layout_gravity="center"
android:gravity="center" android:id="@+id/TableRow3">
        <Spinner android:id="@+id/ConstitutionSpinner"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:entries="@array/string_ability_scores"></Spinner>
        <TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Constitution" android:textSize="30dip"
android:id="@+id/ConstitutionTextView"></TextView>
    </TableRow>
    <TableRow android:layout_height="wrap_content"
android:layout_width="wrap_content" android:id="@+id/tableRow3" android:gravity="center">
        <Spinner android:layout_height="wrap_content"
android:id="@+id/intelligenceSpinner"
android:layout_width="wrap_content"
android:entries="@array/string_ability_scores"></Spinner>
        <TextView android:id="@+id/textView1"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Intelligence" androi开发者_如何学编程d:textSize="30dip"></TextView>
    </TableRow>
    <TableRow android:layout_height="wrap_content"
android:layout_width="wrap_content" android:id="@+id/tableRow4"
android:gravity="center">
        <Spinner android:layout_height="wrap_content"
android:id="@+id/WisdomSpinner" android:layout_width="wrap_content"
android:entries="@array/string_ability_scores"></Spinner>
        <TextView android:id="@+id/textView3"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge" android:text="Wisdom"
android:textSize="30dip"></TextView>
    </TableRow>
    <TableRow android:layout_height="wrap_content"
android:layout_width="wrap_content" android:id="@+id/tableRow5"
android:gravity="center">
        <Spinner android:layout_height="wrap_content"
android:id="@+id/CharismaSpinner" android:layout_width="wrap_content"
android:entries="@array/string_ability_scores"></Spinner>
        <TextView android:id="@+id/textView4"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Charisma" android:textSize="30dip"></TextView>
    </TableRow>
</TableLayout>

Currently, it looks like this:

Fitting all of the views onto one table row

On the top-most spinner there's suppose to be a number to the left. I'm trying to squeeze it on to the screen and have all three fit.


im not sure what you want any way check this and tell me is this what you are trying.

Fitting all of the views onto one table row

if so here is the xml.

<TableRow android:id="@+id/tableRow1">
    <TextView android:text="zero" android:id="@+id/StrengthBonusText"></TextView>
    <Spinner android:id="@+id/StrengthSpinner" />
    <TextView android:id="@+id/StrengthTextView"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="Strength" android:textSize="30dip" />
</TableRow>

<TableRow android:id="@+id/tableRow2">
    <View android:visibility="invisible" android:layout_height="0dip" />
    <Spinner android:id="@+id/dexteritySpinner" />
    <TextView android:id="@+id/textView2" android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="Dexterity" android:textSize="30dip" />
</TableRow>

<TableRow android:id="@+id/TableRow3">
    <View android:visibility="invisible" android:layout_height="0dip" />
    <Spinner android:id="@+id/ConstitutionSpinner"></Spinner>
    <TextView android:id="@+id/ConstitutionTextView"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="Constitution" android:textSize="30dip"></TextView>
</TableRow>
<TableRow android:id="@+id/tableRow3">
    <View android:visibility="invisible" android:layout_height="0dip"/>
    <Spinner android:id="@+id/intelligenceSpinner"></Spinner>
    <TextView android:id="@+id/textView1" android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="Intelligence" android:textSize="30dip"></TextView>
</TableRow>
<TableRow android:id="@+id/tableRow4">
    <View android:visibility="invisible" android:layout_height="0dip"/>
    <Spinner android:id="@+id/WisdomSpinner"></Spinner>
    <TextView android:id="@+id/textView3" android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="Wisdom" android:textSize="30dip"></TextView>
</TableRow>
<TableRow android:id="@+id/tableRow5">
    <View android:visibility="invisible" android:layout_height="0dip"/>
    <Spinner android:id="@+id/CharismaSpinner"></Spinner>
    <TextView android:id="@+id/textView4" android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="Charisma" android:textSize="30dip"></TextView>
</TableRow>


Have you tried using a relative layout or is that just not an option? Also I noticed you are mixing px and dip - this is usually not recommended

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜