2012-02-17 13 views
3

可能性の重複:私のアプリケーションでは
How can I implement a 'Lettrine' render in android?このビュー(レイアウト)の作成方法は?

私はビューに(databseから)のニュースを表示したい、そのために私は下の画像に表示ショーのこのタイプを作成する必要があります。

私は、画像ビューでのTextView 2内のTextView 1でタイトルや説明画像を設定したい... テキストの長さは、それがニュースのページのように見えるべきである

を変更します。下の画像のように。

enter image description here

+0

:http://stackoverflow.com/questions/2248759/how-to-layout-text-to-flow-around -an-image –

答えて

2

あなたはレイアウトではなく、あなたのニュースをHTMLとしてマークアップしてWebViewに入れる方が良いでしょう。

そうでない場合はSpannableを見て、ImageをImageViewとしてTextViewに追加してください(afaik)。テキストのイメージへの配置方法を変更できます。

+0

DBからWebには来ていません。 –

+0

'Html.toHtml()'メソッドを使ってテキスト(文字列など)からHTMLを生成できます。 – OleGG

+1

+1 Androidのすべてのレイアウトはコンテンツが長方形であると想定しています。テキストは必然的にイメージの上、下、または横に表示されます。 OPが望むレトリン効果を作り出すことは不可能です。 – rds

0

OK、擬似コード:

<RelativeLayout> 

<TextView id=TextView2 width/height=fill_parent /> 

<ImageView id=ImageView1 width/height=wrap_content 
     layout_alignparenttop=true layout_alignparent_left=true/> 
<TextView id=TextView1 width/height=wrap_content 
     layout_alignparenttop=true layout_alignparentright=true /> 
</RelativeLayout> 

トリックは親としてRelativeLayoutを使用すること、及びその後、属性のlayout_alignParentXセットが画面上の相対位置を定義することです。また、上記の擬似レイアウトは、TextView2がイメージビューの後ろにあることを前提としています。

+0

そうしたようにレイアウトしますが、実際にTextView2にテキストを置くと、画像の後ろにジャンプするようにカーソル位置を知る必要があります。 – L7ColWinters

+0

.setSelection(n)、あなたがカーソルが – L7ColWinters

+0

に行く場所を指定することができますので、これは解決策ではありません、私はタイトルテキストの後に説明カーソルを開始したいetedとafterイメージテキストは左端から開始する必要があります。 –

0

チェックこのうち、次のようにカスタムビューを使用して可能

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:layout_gravity="center" 
android:background="#ffffff" 
android:orientation="vertical" > 

<TextView 
    android:id="@+id/textView1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true" 
    android:background="#0059A9" 
    android:gravity="center" 
    android:padding="50dip" 
    android:text="TextView 1" /> 

<RelativeLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_below="@+id/textView1" 
    android:layout_marginTop="10dip" 
    android:orientation="horizontal" > 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:background="#0059A9" 
     android:gravity="center" 
     android:padding="50dip" 
     android:text="TextView 1" /> 

    <ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_gravity="left" 

     android:background="#ffffff" 
     android:contentDescription="Image View" 
     android:src="@drawable/image_no" /> 
</RelativeLayout> 

+0

テキストビュー2画像の幅に応じて余白が表示されます。上から下へ、私が望むのは、テキストが画像の後に画像の高さとともに来るべきであるということです。それは画像ビューの下にも来ます。 –

+0

私の編集を今すぐチェックしてください。 – Akram

関連する問題