2011-07-12 4 views
1

長いテキストを250文字(1行、改行なし、改行なし)で表示する必要があります。私の活動のTextViewのために。Android:TextView用の長いテキストを表示

レイアウトのビューにはtextTypeをtextMultiLineとして使用していますが、アクティビティからは長いテキストを渡してview.setText()メソッドを使用しました。

しかし、表示されている画面からテキストが表示されています。

これを修正するにはどうすればよいですか?

おかげで、 Nehatha

+++編集+++++

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" android:layout_height="wrap_content" 
android:orientation="vertical" android:background="@drawable/bg" 
android:gravity="center_horizontal" 
android:id="@+id/rootView"> 
<ScrollView android:id="@+id/ScrollView01" 
    android:layout_width="wrap_content" android:layout_height="wrap_content" 
    android:layout_marginLeft="8dp" android:layout_marginRight="8dp" 
    android:minWidth="310dp" android:scrollbarStyle="outsideOverlay" 
    android:scrollbars="vertical"> 
     <LinearLayout android:orientation="vertical" 
      android:layout_width="fill_parent" android:layout_height="fill_parent"> 
      <FrameLayout android:id="@android:id/tabcontent" 
       android:layout_width="fill_parent" android:layout_height="fill_parent"> 


       <LinearLayout android:id="@+id/tabContentPostDetails" 
        android:layout_width="wrap_content" android:orientation="vertical" 
        android:layout_height="fill_parent"> 

        <TableLayout android:id="@+id/TableLayout01" 
         android:layout_width="fill_parent" android:layout_height="wrap_content" 
         android:gravity="center" 
         android:background="@drawable/transparent_border_shape"> 
         <TableRow android:layout_marginBottom="5dip"> 
          <LinearLayout android:orientation="horizontal" 
          android:layout_width="fill_parent" android:layout_height="wrap_content"> 
           <TextView android:id="@+id/csPostTitle" 
            android:padding="3dip" android:textSize="7pt" 
            android:textColor="@color/Black" 
            android:layout_width="fill_parent" android:layout_height="wrap_content" android:inputType="textMultiLine"/> 
          </LinearLayout> 
         </TableRow> 

         .... 

答えて

1

おそらくlayout_width="wrap_content"を使用しています。これにより、TextViewストレッチがテキストを1行に収めるようになります。 layout_width="fill_parent"(または指定された幅)とlayout_height="wrap_content"を使用してみてください。あなたはTextViewのための次の属性を使用する必要があります

+0

こんにちはグレゴリー、私は "fill_parent"で試したが、まだ私はテキスト全体を見ていない。 –

+0

あなたが持っているものとあなたのレイアウトのスクリーンショットを投稿できますか? – Gregory

+0

こんにちはグレゴリー、オリジナルの投稿を自分のレイアウトコードスニペットで更新しました。@ + id/csPostTitleビューを確認してください。 –

0

:どんな数に

android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:inputType="textMultiLine" 
android:maxLines="10" 

変更10はあなたのために働きます。

私がテストしたレイアウトをした

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    android:background="#ffffff" 
    android:gravity="center_horizontal" 
    android:id="@+id/rootView"> 
    <ScrollView 
     android:id="@+id/ScrollView01" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="8dp" 
     android:layout_marginRight="8dp" 
     android:minWidth="310dp" 
     android:scrollbarStyle="outsideOverlay" 
     android:scrollbars="vertical"> 
     <LinearLayout 
      android:orientation="vertical" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent"> 
      <FrameLayout 
       android:id="@android:id/tabcontent" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent"> 

       <LinearLayout 
        android:id="@+id/tabContentPostDetails" 
        android:layout_width="wrap_content" 
        android:orientation="vertical" 
        android:layout_height="fill_parent"> 

        <TableLayout 
         android:id="@+id/TableLayout01" 
         android:layout_width="fill_parent" 
         android:layout_height="wrap_content" 
         android:gravity="center" 
         android:background="#ffffff"> 
         <TableRow 
          android:layout_marginBottom="5dip" 
          android:background="#ff0000" 
          > 
          <TextView 
           android:id="@+id/csPostTitle" 
           android:background="#00ff00" 
           android:padding="3dip" 
           android:textSize="7pt" 
           android:textColor="#000000" 
           android:layout_width="wrap_content" 
           android:layout_height="wrap_content" 
           android:inputType="textMultiLine" 
           android:maxLines="10" 
           android:text="this is a very long text. so long that it does not ghave any breaks whasoever. this is a test to see if the line dissplayes proper;ly." /> 

          <LinearLayout 
           android:orientation="horizontal" 
           android:layout_width="fill_parent" 
           android:layout_height="wrap_content"> 
          </LinearLayout> 
         </TableRow> 
        </TableLayout> 
       </LinearLayout> 
      </FrameLayout> 
     </LinearLayout> 
    </ScrollView> 
</LinearLayout> 
+0

こんにちはマンデル、これは私のために働いていない、まだテキストが1行で表示され、私は可視の画面からテキストを見ることができません。 –

+0

私がテストしたレイアウトを見てください。おそらく、言及するのを忘れた他のいくつかの変更があります。あなたが持っているものと上記のレイアウトを比較してください。 – Mandel

+0

@マンデル:ありがとう、あなたは私の時間を救った.... – Surej

1

それはこのような状況で私を助けた何をあなたに

0

を助けるだろうと思い.I android:maxEms="15"を試してみてください、このようなlayout_gravity="fill_vertical"を設定しました:

<TextView 
     android:id="@+id/list_e_taskdesc" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:layout_gravity="fill_vertical" 
     android:text="@string/empty_label1"/> 
関連する問題