簡體   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