2013-10-28 3 views
0

새로운 문제가 있습니다.android는 ms office 텍스트 상자와 같은 textview를 만듭니다.

프로젝트는 배경으로 비트 맵을 사용하여 텍스트 뷰를 필요로하지만 (사용자는 9 패치로 만들 수 있음) 사용자가 마우스를 사용하여 크기를 조정할 수있는 ms 오피스의 텍스트 상자처럼 제스처로 너비와 높이의 크기를 조정할 수 있습니다 텍스트 상자와 텍스트가 다시 게시됩니다.

내 코드는 다음과 같습니다. 이것은 텍스트보기의 속성을 저장하기 위해 아래로 마크하는 것입니다. publicET는 텍스트 뷰입니다.

   TextObject tObj = new TextObject(); 
       tObj.setId(Integer.parseInt(String.valueOf(id))); 
       tObj.setPageId(getPageNum); 
       tObj.setAlbumId(albumId); 
       tObj.setContent(publicET.getText().toString()); 
       tObj.setPositionX(textPositionX); 
       tObj.setPositionY(textPositionY); 
       tObj.setLength(textPositionB); 
       tObj.setWidth(textPositionR); 
       tObj.setColor(curPicBackColor); 
       tObj.setSize(curTextFontSize); 
       tObj.setTextFont(typefacestr); 
       publicET.setTag(tObj); 
       publicET.setBackgroundDrawable(null); 

TestObject 클래스는 다음과 같이이다 : 나는이 텍스트 뷰를 보여

   ts.setPositionX(publicET.getLeft()); 
       ts.setPositionY(publicET.getTop()); 
       ts.setLength(publicET.getBottom()); 
       ts.setWidth(publicET.getRight()); 

2.then, 나는 텍스트 뷰의 속성을 설정

public class TextObject { 

private Integer id; 
private Integer pageId; 
private Integer albumId; 
private String content; 
private Integer positionX; 
private Integer positionY; 
private Integer length; 
private Integer width; 
private String color; 
private Integer size; 
private String textFont; 

public Integer getId() { 
    return id; 
} 
public void setId(Integer id) { 
    this.id = id; 
} 
public Integer getPageId() { 
    return pageId; 
} 
public void setPageId(Integer pageId) { 
    this.pageId = pageId; 
} 
public Integer getAlbumId() { 
    return albumId; 
} 
public void setAlbumId(Integer albumId) { 
    this.albumId = albumId; 
} 
public String getContent() { 
    return content; 
} 
public void setContent(String content) { 
    this.content = content; 
} 
public Integer getPositionX() { 
    return positionX; 
} 
public void setPositionX(Integer positionX) { 
    this.positionX = positionX; 
} 
public Integer getPositionY() { 
    return positionY; 
} 
public void setPositionY(Integer positionY) { 
    this.positionY = positionY; 
} 
public Integer getLength() { 
    return length; 
} 
public void setLength(Integer length) { 
    this.length = length; 
} 
public Integer getWidth() { 
    return width; 
} 
public void setWidth(Integer width) { 
    this.width = width; 
} 
public String getColor() { 
    return color; 
} 
public void setColor(String color) { 
    this.color = color; 
} 
public Integer getSize() { 
    return size; 
} 
public void setSize(Integer size) { 
    this.size = size; 
} 
public String getTextFont() { 
    return textFont; 
} 
public void setTextFont(String textFont) { 
    this.textFont = textFont; 
} 

}

내가 할 수있는 이 텍스트 뷰의 속성을 올바른 위치에 표시하도록 제어하지 않습니다. 로그로 위치를 확인했습니다. 나를 도울 수 있기를 고대합니다. 고맙습니다.

+0

내가 지금 해결책을 발견했다. 텍스트 뷰의 너비를 설정하여 레이아웃 매개 변수를 설정하고 textview.setWidth (intpx)와 동일하게 작동합니다. – arjinmc

+0

솔루션을 답변으로 추가하고 동의하면 질문이 닫힙니다. – sandrstar

+1

나는 이미 그것을 제기했다. – arjinmc

답변

0

이 내 코드이며 작동합니다

RelativeLayout.LayoutParams paramst = new RelativeLayout.LayoutParams(
       android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 
       android.view.ViewGroup.LayoutParams.WRAP_CONTENT); 
     paramst.setMargins(o.getPositionX(), o.getPositionY(), 
       o.getWidth(), o.getLength()); 
     TextView e = new TextView(this);   
     e.setBackgroundResource(R.drawable.edittext_bg2); 
     e.setLayoutParams(paramst); 
     e.setWidth(o.getWidth()-o.getPositionX()); 
관련 문제