繁体   English   中英

通过xml或java在android中的缩写

[英]abbreviations in android via xml or java

首先。 我试图在stackoverflow中搜索我的问题,但没有找到确切的答案,但是有一些相关的问题,但是这些并不是我的问题的答案。 可能是我不知道我们要问你的那件事。

我正在eclipse中创建一个xml文件,其中将显示单词的缩写。

例如fb:facebook //未为更大的屏幕添加新行gm:gmail sof:流量叠加

这些只是示例。

在我的代码中,我想创建2个textview或类似的东西,第一个textview将显示缩写,而第二个将显示该缩写的确切英语。 但有时在小屏幕上,该缩写可能不在屏幕上,或者可能包含/ n或换行符,而我的所有其他缩写都将像此示例一样是错误的。

fb: face //a new line added for small screen
gm: book
sof: gmail
:stack over flow

基本上我想让你告诉我如何安排代码,以便textview可以滚动而不包括新行。 或者,如果textview2包含enter,那么textview1也应该包含一个enter。 请帮我

您应该使用TableLayout类和Horizo​​ntalScrollView
只要尝试这样的事情

<HorizontalScrollView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height=wrap_content"
        android:fillViewport="true">
            <TableLayout
                    android:layout_width="wrap_content"  <!-- text should go along one line for each row-->
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    android:stretchColumns="*">

                <TableRow
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="horizontal">

                    <TextView
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:singleLine="true" 
                            android:text="fb:"/>
                                         <!-- when singleLine atrubutte set : ) -->
                     <TextView
                           android:layout_width="wrap_content"
                           android:layout_height="wrap_content"
                           android:singleLine="true"
                           android:text="facebook"/>
                </TableRow>
             </TableLayout>

 </ScrollView>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM