2012-02-17 2 views
3

가능한 중복 : 내 응용 프로그램에서
How can I implement a 'Lettrine' render in android?이보기 (레이아웃)를 만드는 방법은 무엇입니까?

내가 그것을 위해 내가보기의 유형을 만들어야합니다, 뷰에 (, 데이타베이스에서) 뉴스를 표시하려면 아래 이미지를 보여줍니다 .

내가 이미지보기에서 이미지를 설정하려면, 텍스트 뷰 2에서 텍스트 뷰 하나의 제목과 설명 .. 텍스트 길이는

은 뉴스 페이지처럼 보이게해야한다 다를 수 있습니다. 아래 그림과 같습니다.

enter image description here

+0

수 같은 사용자 지정보기를 사용하여 : http://stackoverflow.com/questions/2248759/how-to-layout-text-to-flow-around - 예 - –

답변

2

레이아웃을 사용하지 말고 뉴스를 HTML로 마크 업하고 WebView에 넣는 것이 좋습니다.

그렇지 않으면 Spannable을보고 ImageSpan을 ImageView로 TextView에 추가하고 afaik는 텍스트가 이미지와 정렬되는 방식을 수정할 수 있습니다.

+0

DB에서 웹에서 오는되지 않습니다. –

+0

'Html.toHtml()'메서드를 사용하여 텍스트 (예 : 문자열)에서 HTML을 생성 할 수 있습니다. – OleGG

+1

+1 안드로이드의 모든 레이아웃은 콘텐츠가 직사각형이라고 가정합니다. 텍스트는 반드시 이미지 위, 아래 또는 옆에 있어야합니다. OP가 원하는 문자 효과를 만드는 것은 불가능합니다. – rds

0

확인, 사이비 코드 :

<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 세트는 화면에 상대적인 위치를 정의 할 수 있습니다. 또한, 위의 psuedo 레이아웃은 TextView2가 이미지보기 뒤쪽에 있다고 가정합니다.

+0

예를 들자면, TextView2에 실제로 텍스트를 놓을 때 그는 커서 위치를 알아야 이미지가 끝날 때까지 점프 할 수 있습니다. – L7ColWinters

+0

.setSelection (n), textView 커서가 – 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

관련 문제