简体   繁体   中英

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. 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.

for example fb: facebook //no new line added for bigger screen gm: gmail sof: stack over flow

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. 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.

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. or if textview2 include enter than textview1 should have an enter too. please help me

You should use TableLayout class and HorizontalScrollView
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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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