请在的TableRow第二TextView的滚动如果文本太长 [英] Make the second Textview in a TableRow scrollable if the text is too long
问题描述
我有一个表的布局像招呼,今天-.- Android开发-wow网站tablelayout已关闭。有2 textviews 1的TableRow,1应在离开现场。
第二应固定在右侧。但我有2个textviews谁是长于屏幕。如果我启动应用程序,我只看到长textviews中间/结束,短期是正确的在屏幕后面。我怎样才能让固定在屏幕左边侧短textviews?
我希望你明白我的意思,我的英语很糟糕,但我认为我的问题的内容是清楚的。
这仅仅是第一部分^^ XML文件是更长的时间
下面是XML文件:
<?XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:方向=垂直> <滚动型
的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:isScrollContainer =真
机器人:overScrollMode =总是
机器人:scrollbarAlwaysDrawVerticalTrack =真
机器人:scrollbarStyle =outsideInset
机器人:滚动条=垂直>
< TableLayout
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:stretchColumns =1>
<的TableRow
机器人:ID =@ + ID / tableRow0
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT>
<的TextView
机器人:layout_column =1
机器人:填充=3dip
机器人:TEXTSIZE =20dp
机器人:文字=@字符串/ tab1_text1
机器人:文字颜色=#FFFFFF
机器人:layout_marginTop =5DP
/>
< /&的TableRow GT;
<查看
机器人:layout_height =2DIP
机器人:背景=#FF909090/> <的TableRow
机器人:ID =@ + ID / tableRow1
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT>
<的TextView
机器人:layout_column =1
机器人:填充=3dip
机器人:文字=@字符串/ TV_1_1机器人:文字颜色=#FFFFFF/> <的TextView
机器人:ID =@ + ID / in1_1
机器人:重力=右
机器人:填充=3dip
机器人:文字=TEXT2机器人:文字颜色=#FFFFFF/> < /&的TableRow GT;
<的TableRow
机器人:ID =@ + ID / tableRow2
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT> <的TextView
机器人:layout_column =1
机器人:填充=3dip
机器人:文字=@字符串/ TV_1_2机器人:文字颜色=#FFFFFF/>
<的TextView
机器人:ID =@ + ID / in1_2
机器人:重力=右
机器人:填充=3dip
机器人:文字=TEXT2机器人:文字颜色=#FFFFFF/> < /&的TableRow GT; <的TableRow
机器人:ID =@ + ID / tableRow3
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT>
<的TextView
机器人:layout_column =1
机器人:填充=3dip
机器人:文字=@字符串/ TV_1_3机器人:文字颜色=#FFFFFF/>
<的TextView
机器人:ID =@ + ID / in1_3
机器人:重力=右
机器人:填充=3dip
机器人:文字=TEXT2
机器人:文字颜色=#FFFFFF
机器人:单线=真
机器人:ellipsize =金字招牌
机器人:marqueeRepeatLimit =marquee_forever
机器人:可聚焦=真
机器人:focusableInTouchMode =真
机器人:scrollHorizontally =真
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
/> < /&的TableRow GT;
你的问题有点难懂,但是看着在评论您的插图,我认为你需要你的体重TextViews。看看下面的例子。
请注意:这不会伸展你的左边列,如你在TableLayout样品code曾表示
。 < TableLayout的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT> <&的TableRow GT;
<的TextView
机器人:layout_width =0dp
机器人:layout_height =WRAP_CONTENT
机器人:layout_weight =1
机器人:单线=真
机器人:ellipsize =金字招牌
机器人:填充=3DP
机器人:文字=你好layout_weight/> <的TextView
机器人:layout_width =0dp
机器人:layout_height =WRAP_CONTENT
机器人:layout_weight =1
机器人:单线=真
机器人:填充=3DP
机器人:重力=右
机器人:scrollHorizontally =真
机器人:文本=行1,西1/>
< /&的TableRow GT; <&的TableRow GT;
<的TextView
机器人:layout_width =0dp
机器人:layout_height =WRAP_CONTENT
机器人:layout_weight =1
机器人:单线=真
机器人:ellipsize =金字招牌
机器人:填充=3DP
机器人:文字=在您的左边一列长一些文字,以半个屏幕宽度
/> <的TextView
机器人:layout_width =0dp
机器人:layout_height =WRAP_CONTENT
机器人:layout_weight =1
机器人:填充=3DP
机器人:文字=这是在你的右列长滚动文本
机器人:单线=真
机器人:ellipsize =金字招牌
机器人:marqueeRepeatLimit =marquee_forever
机器人:可聚焦=真
机器人:focusableInTouchMode =真
机器人:scrollHorizontally =真
/> < /&的TableRow GT;
< / TableLayout>
i have a table layout like the hello, tablelayout on android dev -wow the site is down today -.- . There are 2 textviews in 1 tableRow, the 1 should be at the left site.
The second should be fixed at the right side. But i have 2 textviews who are longer than the screen. If i start the application, i only see the middle /end of the long textviews, the short are right behind the screen. How can i make the short textviews fixed at the left screen side ?
I hope you know what i mean, my english is very bad but i think the content of my question is clear.
This is only the first part^^ the xml file is much longer Here is the xml file :
<?xml version="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" >
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:isScrollContainer="true"
android:overScrollMode="always"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:scrollbarStyle="outsideInset"
android:scrollbars="vertical" >
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stretchColumns="1">
<TableRow
android:id="@+id/tableRow0"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:layout_column="1"
android:padding="3dip"
android:textSize="20dp"
android:text="@string/tab1_text1"
android:textColor="#ffffff"
android:layout_marginTop="5dp"
/>
</TableRow>
<View
android:layout_height="2dip"
android:background="#FF909090" />
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:layout_column="1"
android:padding="3dip"
android:text="@string/TV_1_1" android:textColor="#ffffff"/>
<TextView
android:id="@+id/in1_1"
android:gravity="right"
android:padding="3dip"
android:text="TEXT2" android:textColor="#ffffff"/>
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:layout_column="1"
android:padding="3dip"
android:text="@string/TV_1_2" android:textColor="#ffffff"/>
<TextView
android:id="@+id/in1_2"
android:gravity="right"
android:padding="3dip"
android:text="TEXT2" android:textColor="#ffffff"/>
</TableRow>
<TableRow
android:id="@+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:layout_column="1"
android:padding="3dip"
android:text="@string/TV_1_3" android:textColor="#ffffff"/>
<TextView
android:id="@+id/in1_3"
android:gravity="right"
android:padding="3dip"
android:text="TEXT2"
android:textColor="#ffffff"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit ="marquee_forever"
android:focusable="true"
android:focusableInTouchMode="true"
android:scrollHorizontally="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</TableRow>
Your question was a bit difficult to understand, but looking at your illustration in the comments, i think you need to weight your TextViews. Take a look at the example below.
Note: this will not stretch your left column, as you had indicated in your TableLayout sample code.
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TableRow>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:singleLine="true"
android:ellipsize="marquee"
android:padding="3dp"
android:text="Hello layout_weight" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:singleLine="true"
android:padding="3dp"
android:gravity="right"
android:scrollHorizontally="true"
android:text="Row 1, Col 1" />
</TableRow>
<TableRow>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:singleLine="true"
android:ellipsize="marquee"
android:padding="3dp"
android:text="Some long text in your left column, taking half the screen width"
/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="3dp"
android:text="This is the long scrolling text in your right column."
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:focusable="true"
android:focusableInTouchMode="true"
android:scrollHorizontally="true"
/>
</TableRow>
</TableLayout>
这篇关于请在的TableRow第二TextView的滚动如果文本太长的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!