简体   繁体   English

通过xml或java在android中的缩写

[英]abbreviations in android via xml or java

first of all. 首先。 i have tried searching my question in stackoverflow and not founded the exact answer there are some related questions but those are not the answer of my questions. 我试图在stackoverflow中搜索我的问题,但没有找到确切的答案,但是有一些相关的问题,但是这些并不是我的问题的答案。 may be i dont know what we call that thing which i gonna ask you. 可能是我不知道我们要问你的那件事。

i am creating an xml file in eclipse in which i am going to show abbreviations of words. 我正在eclipse中创建一个xml文件,其中将显示单词的缩写。

for example fb: facebook //no new line added for bigger screen gm: gmail sof: stack over flow 例如fb:facebook //未为更大的屏幕添加新行gm:gmail sof:流量叠加

these are just examples. 这些只是示例。

in my code i want to create 2 textviews or something like that first textview will show the abbreviations and 2nd will show the exact English for that abbreviation. 在我的代码中,我想创建2个textview或类似的东西,第一个textview将显示缩写,而第二个将显示该缩写的确切英语。 but some times on small screens the abbreviation may go out of screen or may include /n or new line and my all other abbreviations will be wrong like this example. 但有时在小屏幕上,该缩写可能不在屏幕上,或者可能包含/ n或换行符,而我的所有其他缩写都将像此示例一样是错误的。

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

basically i want you to tell me that how to arrange the code so the textview should either scroll and do not include the new line. 基本上我想让你告诉我如何安排代码,以便textview可以滚动而不包括新行。 or if textview2 include enter than textview1 should have an enter too. 或者,如果textview2包含enter,那么textview1也应该包含一个enter。 please help me 请帮我

You should use TableLayout class and HorizontalScrollView 您应该使用TableLayout类和Horizo​​ntalScrollView
Just try something like this 只要尝试这样的事情

<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